1748026 Members
3857 Online
108757 Solutions
New Discussion юеВ

abouy cron job

 
SOLVED
Go to solution
lin.chen
Frequent Advisor

abouy cron job

I have a crontab,but it seems it can not run successfully.But I can run it manually.
#!/bin/ksh
typeset -i weekdayb
weekdayb=`date +%u`
typeset -i tapeslotb
tapeslotb=${weekdayb}+20
/opt/omni/lbin/uma -ioctl /dev/rac/c12t0d0 <move S$tapeslotb D2
exit
EOF

crontab -l
50 20 * * * /home/move.sh 1>>/home/scripts/LOGS/move_tape_to_D2.sh.log 2>&1 &

who can help me to find why the cron job can not take effect, while I can manually run it?
Louis
4 REPLIES 4
Steven E. Protter
Exalted Contributor
Solution

Re: abouy cron job

Shalom

In your cron job

env > /tmp/cronjob.txt

from command line

env > /tmp/notcronjob.txt

cron has no PATH or any other variable. That is why your cron job does not work.

If you set PATH in your job and other important environmental variables from normal run environment, your cron job will start to work.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Dennis Handly
Acclaimed Contributor

Re: abouy cron job

As SEP mentions it is related to the truncated ENV that exists. See crontab(1):
http://docs.hp.com/en/B2355-60130/crontab.1.html

What is logged in your logfile?

>SEP: cron has no PATH

This isn't true. It is limited to: PATH=/usr/bin:/usr/sbin:.

This should cover date(1).
Steven E. Protter
Exalted Contributor

Re: abouy cron job

Correct Dennis,

cron has a limited PATH variable.

Doesn't really change anything, establishing a proper PATH variable fixed the script.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Peter Nikitka
Honored Contributor

Re: abouy cron job

Hi,

at first I would drop the backgrounding of the cronjob - reomove the last '&'.
The next question is, what does your logfile say?

mfG Peter
The Universe is a pretty big place, it's bigger than anything anyone has ever dreamed of before. So if it's just us, seems like an awful waste of space, right? Jodie Foster in "Contact"