How to debug a cronjob:
- Check for cron output. Output will generally be sent to the user's
mail account. Type "mail" to see if mail exists from this run. If so, a
helpful error message should appear. If not, continue.
- Check the cron logfile for helpful error messages. This is file is
probably /var/log/cron but it may be different on your system.
- Run the script or command on your command line to see if any helpful
error messages appear.
- Use the "at" command to run the script cron-like immediately e.g.,
"at -f scriptname now". Type "mail" and check for output to see of there
are any helpful error messages. Type "man at" for more info on "at".
- Direct the output of your cronjob to an easily accessible discfile:
15 10 * * * /home/cfmc/runment 2> /home/cfmc/mentout
The "2>" part should allow the inclusion of error messages as well.
- Also when running multiple command statements in the same crontab line you will want to make sure to surround the crontab with quotes as seen in the example below:
#Start up the CDI and then then Stdysrvr and initializes the dialer
11 04 * * * csh -c "setenv CFMC /cfmc/; setenv CFMCCFG /cfmc/ipcfiles/; /cfmc/go/init_cdi > /home/cfmc/.bin/init_cdi.log"