Crontab variable...


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Crontab variable...
# 1  
Old 08-17-2006
Crontab variable...

AIX,

Why does this work:
0 8 * * * export TEST=mytest;echo "Hello" > $HOME/$TEST.log 2>&1

But not this (or any variations thereof):

0 8 * * * export LOGFILE=$(date +%Y%m%d);echo "Hello" > $HOME/$LOGFILE.log 2>&1

Is it possible to set variables this way in cron?? It will work also if like this:

0 8 * * * ksh somefile.ksh;echo "Hello" > $HOME/$LOGFILE.log 2>&1

where somefile.ksh has "export LOGFILE=`date +%Y%m%d`" but I don't want to do it this way. I want to chain the commands in cron.

Gianni

Last edited by giannicello; 08-17-2006 at 11:47 AM..
# 2  
Old 08-18-2006
Everything after a % is stripped off and fed to the command as standard input.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to redirect 'crontab' output to a variable?

I'm trying to redirect the output of crontab to a variable named "crontab_status" as below: crontab_status=$(crontab -l) executing the script is not redirecting to the variable. Please help! (6 Replies)
Discussion started by: mjavalkar
6 Replies

2. Shell Programming and Scripting

[Solved] How to increment and add variable length numbers to a variable in a loop?

Hi All, I have a file which has hundred of records with fixed number of fields. In each record there is set of 8 characters which represent the duration of that activity. I want to sum up the duration present in all the records for a report. The problem is the duration changes per record so I... (5 Replies)
Discussion started by: danish0909
5 Replies

3. Red Hat

How to pass value of pwd as variable in SED to replace variable in a script file

Hi all, Hereby wish to have your advise for below: Main concept is I intend to get current directory of my script file. This script file will be copied to /etc/init.d. A string in this copy will be replaced with current directory value. Below is original script file: ... (6 Replies)
Discussion started by: cielle
6 Replies

4. UNIX for Dummies Questions & Answers

How to retrieve the value of variable in shell script which is called by crontab

There are two files one is shell script (sample.sh) and another is configuration file (sampl_conf.cfg) configuration file contains one variable $FTP_HOME. the value of this variable vaires for user to user. If user is say jadoo then value is /home/jadoo/ftp/, for user1 - /home/user1/ftp. The... (4 Replies)
Discussion started by: jadoo_c2
4 Replies

5. Shell Programming and Scripting

environment variable in shell script called through crontab

Please help me on below.. https://www.unix.com/shell-programming-scripting/141533-retrieve-value-environment-variable-shell-script-called-crontab.html#post302442024 I'm still here. I can still see you! (0 Replies)
Discussion started by: jadoo_c2
0 Replies

6. Shell Programming and Scripting

Retrieve the value of environment variable in shell script which called from crontab

There are two files one is shell script (sample.sh) and another is configuration file (sampl_conf.cfg) configuration file contains one variable $FTP_HOME. the value of this variable vaires for user to user. If user is say jadoo then value is /home/jadoo/ftp/, for user1 - /home/user1/ftp. The... (0 Replies)
Discussion started by: jadoo_c2
0 Replies

7. UNIX for Dummies Questions & Answers

Variable problem in script when using crontab

Hi, this is my first shell script. Anyway i am trying to ftp files from one machine to another. The name of the script is ifsftp_orabkp. The code is as follows: HOST="122.122.122.22" USER="ftp_ftp" PASSWD="ftp.222222" Y1=`(perl -e '@y=localtime(time());printf... (11 Replies)
Discussion started by: dazz
11 Replies

8. Shell Programming and Scripting

How to define a variable with variable definition is stored in a variable?

Hi all, I have a variable say var1 (output from somewhere, which I can't change)which store something like this: echo $var1 name=fred age=25 address="123 abc" password=pass1234 how can I make the variable $name, $age, $address and $password contain the info? I mean do this in a... (1 Reply)
Discussion started by: freddy1228
1 Replies

9. Shell Programming and Scripting

Insert a line including Variable & Carriage Return / sed command as Variable

I want to instert Category:XXXXX into the 2. line something like this should work, but I have somewhere the wrong sytanx. something with the linebreak goes wrong: sed "2i\\${n}Category:$cat\n" Sample: Titel Blahh Blahh abllk sdhsd sjdhf Blahh Blah Blahh Blahh Should look like... (2 Replies)
Discussion started by: lowmaster
2 Replies

10. Shell Programming and Scripting

Not able to print variable value in crontab entry

Hi, I just stuckup to echo a variable that is assigned in .profile file from a crontab entry. I have a entry in .profile as, CONF_FILE_PATH=/home/test/conf export CONF_FILE_PATH I am able to echo it in command line but I am not able to print $CONF_FILE_PATH when i scheduled it in... (4 Replies)
Discussion started by: naren_0101bits
4 Replies
Login or Register to Ask a Question