Saturday, June 02, 2007

Create a Crontab That Preserves Existing Entries

I've had a few queries on how to create a new crontab that preserves the existing entries.

You will need to ensure that the user making the edits has cron permissions -- check /etc/cron.d/cron.allow and /etc/cron.d/cron.deny. Note: for the first example, you may have to set the EDITOR variable. Here's the syntax.

#cd /var/spool/cron/crontabs
#crontab -l > esofthub
#crontab -e esofthub
make your edits
:wq!

OR

#vi esofthub
make your edits
:wq!
#crontab esofthub

FYI: What do the six fields mean
minute 1-60
hour 0-23
day of month 1-31
month of year 1-12
day of week 0-6 (zero is Sunday)
Your edit/addition/script

The following entry will kick off every minute
* * * * * echo "I'm kicked off every minute"