Showing results for 
Search instead for 
Did you mean: 

crontab not working


crontab not working

I have scheduled a script in crontab.
When i tried to run the script manually its working.

But in crontab its not running.

entry is::

13 13 * * 3 /usr/bin/sh /UX-DR/IS/syslog/

every wednesday 01.13 PM i need to run.

Please help where i can check the error.
What may the possible error
Viktor Balogh
Honored Contributor

Re: crontab not working

Catch the output of the script by redirecting the stdout and stderr to a file:

13 13 * * 3 /usr/bin/sh /UX-DR/IS/syslog/ 1>/tmp/ 2>/tmp/

look for possible errors in that file. The most frequent problem with a cron script is, that it does not inherit the environmental variables from your shell. (like PATH)
So probably you forgot to use declaring commands with full path. But look at the output and you'll see the problem.
Unix operates with beer.
Honored Contributor

Re: crontab not working

Check your environment differences between command line and cron.

$ env > /tmp/mycommandline.env

and add that command to your script
env > /tmp/mycron.env

Then check that you are giving the full path to commands in your script.

Read the man page on cron, crontab for further information such as:

The shell is invoked from your $HOME directory with an arg0
of sh. Users who desire to have their .profile executed must
explicitly do so in the crontab file.
HP-UX been always lovable - Mani Kalra
Honored Contributor

Re: crontab not working

Do check !!

1. File permission (execute permission).
2. Path of the script (specify the complete path), from your example the file should be located in root (/).
HP-UX been always lovable - Mani Kalra
Steven E. Protter
Exalted Contributor

Re: crontab not working


Is cron running?

ps -ef | grep cron


Check /etc/rc.config.d/cron

Make sure it is set to auto start.

/sbin/init.d/cron start

Also note that the environment on cron is different than the user environment.

PATH and such needs to be set in your script.

env > /tmp/env.txt

Good diagnostic tool for the script being run in cron

Steven E Protter
Owner of ISN Corporation
Trusted Contributor

Re: crontab not working

If the user account which is to run the cron job is disabled or locked out, it can prevent cron jobs from running as well.

Re: crontab not working

>13 13 * * 3 /usr/bin/sh /UX-DR/IS/syslog/

This should work. Do you get any mail with any error messages?

Typically you don't need to use /usr/bin/sh in your crontab entry.
You should have "#!/usr/bin/sh" in your script.