Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

crontab not working 2

Status
Not open for further replies.

gatetec

MIS
Mar 22, 2007
420
US
Under root's crontab, I have:

30 0 * * * /usr/es/sbin/cluster/utilities/clsnapshot -c -i -n 'app1_'`date1` -d 'app1_'`date1`

This works fine if I run it manually, but, under crontab, it doesn't work by itself.

"date1" is the alias I created.

root # date1
08Apr081542Tue

Please advise.

thx much


 
Under cron you don't inherit the users environment you need to source his .profile to re-establish his environment and the aliases you set.
 

root:> more .profile

alias date1="date +%y%h%d%H%M%a"

root:/usr/local/bin> more date1

#!/usr/bin/ksh
date +%y%h%d%H%M%a

I have put it under /usr/local/bin as well.
What am I missing here?

thx much
 
Forward the output of that command to a file and check it for errors!

30 0 * * * /usr/es/sbin/cluster/utilities/clsnapshot -c -i -n 'app1_'`date1` -d 'app1_'`date1` 1>/tmp/cllog.txt 2>&1

Regards,
Khalid
 
cron probably doesn't look any further than the dirs listed in the PATH variable as specified in /etc/environment. So if /usr/local/bin isn't there, cron won't find your date1 script.


HTH,

p5wizard
 
thx so much!

/usr/local/bin wasn't there indeed.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top