1834136 Members
2146 Online
110064 Solutions
New Discussion

cron job not working!

 
Mark Porter_1
Occasional Contributor

cron job not working!

I am trying to submit a script via cron and it does not seem to be working - it fact it does nothing at all.
I have added the time and script path into the crontab file and the script works when it is run manually - it is being run as root.
I have no idea why it is not working can anyone help
Thanks

Mark.
6 REPLIES 6
Praveen Bezawada
Respected Contributor

Re: cron job not working!

Hi
First thing to do is to check the cron logs in
/var/adm/cron/log
is anything being written in that log. If 'no' check if cron is running
ps -ef | grep cron
If log is being written, you may not be setting the environment in your script. Cron does not login when running a script so all the setting we generally do in .profile will not be set. So all the environment setting need to be explicitly done in your script.
And if cron is not running, set the value of parameter cron to 1 in /etc/rc.config.d/cron and run the script /sbin/init.d/cron as
/sbin/init.d/cron start
This will start the cron daemon.
Hope this helps.

...BPK...

Robin Wakefield
Honored Contributor

Re: cron job not working!

Hi Mark,

A few things to look for:

. Check the cron has re-read the update crontab file.
. Check the /var/adm/cron/log for any exit code (rc=nnn)
. Check root's mailbox for any error messages.

Rgds, Robin.
Mark Porter_1
Occasional Contributor

Re: cron job not working!

Hi - thanks for the quick reply but I have just noticed what the problem is - I have been putting the days of the week I want it to run into the month field. I have swapped them arround amd all seems to be fine.

Thanks again

Mark.
Kevin Wright
Honored Contributor

Re: cron job not working!

The above post is right, it is probably an ENV thing..also check if your appending to files..>>file..make sure file exists..also, you could try to set the SUID bit on the script to root..chmod 4755 file..see the post below for more info on SUID..as stated, sometimes it works, some not.
Joseph Chakkery
Valued Contributor

Re: cron job not working!

Hello,

Just a thought in mind. Have u given full path name for the script in the cron job? If not try with full path name.

eg:0 5 * * 0-6 /application/action/bin/aSYbdf.ksh

This cron job everyday morning at 5. The scripts full path is given

Hope this may help u.

Regards
Joe.
Knowledge is wealth
Magdi KAMAL
Respected Contributor

Re: cron job not working!

Hi Mark,

Try executing your profile file as first instruction in your crontab script like :

. /home/.../.profile

This will set all environment variables that you need. When a cron is launched, only four or five environment variables are set.

Just to verify :
create a dummy crontab script and add only one line in it : with the "env" command.

type the same command "env" online and compare, the difference will explains why your crontab script is not running.

Magdi