[CentOS] cat cron jobs into crontab

Stephen Harris lists at spuddy.org
Tue Mar 13 04:13:48 UTC 2007


On Mon, Mar 12, 2007 at 08:58:46PM -0400, Matt Hyclak wrote:
> On Mon, Mar 12, 2007 at 05:21:47PM -0800, Karl R. Balsmeier enlightened us:
> > What's the best/safest way to "cat" the following job into crontab?
> > 
> > */3 * * * *  /usr/lib64/nagios/plugins/check_megaraid_passive.sh > 
> > /dev/null 2>&1

> echo '*/3 * * * *  /usr/lib64/nagios/plugins/check_megaraid_passive.sh > /dev/null 2>&1' > /etc/cron.d/check_megaraid_passive.sh

NOTE: MISSING "root" after the time spec.  
  */3 * * * * root /usr/lib64/.....

This is the "new" way of doing it, using a feature of new versions of cron
to scan a directory to get the cron information.

The old style method would be:
  crontab -l > /tmp/afile$$
  echo '*/3 * * * * /usr/lib64/...' >> /tmp/afile$$
  crontab /tmp/afile$$
  rm /tmp/afile$$

The "new style" is much more suitable for scripting; in particular you can
create RPMs that magically drop entries into the cron.d directory.

Rgds
Stephen



More information about the CentOS mailing list