[KLUG Members] Cron

members@kalamazoolinux.org members@kalamazoolinux.org
Sun, 14 Sep 2003 09:28:59 -0400


The stdout and stderr should come to you as a mail message, so if its 
running at all you should be able to see what is failing from looking at 
  that.

You get a very minimal environment from a cron script. It doesn't run 
the systemwide login command file or your own, so at the very least you 
should include the full path of any executable you want to run.

For my cron jobs I always use a shell script, and I run them from 
another shell script that sets up the environment first. This is an 
example of that script from an AIX box that uses ksh instead of bash:


#
#   execute the systemwide sh login command file
#
     if [ -f /etc/profile ] ; then
         . /etc/profile
     fi
#
#   execute the local ksh login command file
#
     if [ -f $HOME/.profile ] ; then
         . $HOME/.profile
     fi
#
     if [ $# -ge 1 ] ; then
         ksh $*
     fi


When you get your script running you will probably want to turn off the 
mail messages from cron. To do so add " >/dev/null 2>/dev/null" to the 
end of your cron line.