you can edit your crontab (the Cron file that controls execution for a specific user) by using the 'contab -e' command, this will fire up vi (or something like it) so you can edit the file. If you (like some of my friends) find Vi evil you can edit the file directly, which is probably in /var/spool/cron/crontabs/<username>
Heres a bit of my crontab for root on my server:
==========================================================
0-59/5 * * * * /sbin/rmmod -a
0-59/15 * * * * /sbin/ddupcron.sh jharris.homeip.net > /dev/null 2>&1
0 0,6,12,18 * * * /sbin/ntpdate.sh
59 * * * * /usr/local/bin/webalizer > /dev/null 2>&1
==========================================================
The first line runs 'rmmod -a' every 5 minutes, the second runs 'ddupcron.sh' every 15 minutes - note the redirection of stdout & stderr. Any output produced by a command that is executed by Cron is emailed to the user, this would mean that every 15mins root would get an email!
The third command runs 'ntpdate.sh' on minute zero of hours 0, 6, 12, and 18. Seeing a pattern yet? The star means all.
So its goes something like
mins hours day-of-month month weekday command
so to execute something every 30 mins every 16th day of every month (why?!?) you would use
30 * 16 * * myCommand
The weekday entry changes per system, on BSD its normally 1-7 where 1 is Monday, on SysV is normally 0-6 where 0 is Sunday. As Linux comes from both I dunno which is which. Nothing that a man page couldn't sort out. Here are the other examples from 'man crontab'
# MIN HOUR DAY MONTH DAYOFWEEK COMMAND
# at 6:10 a.m. every day
10 6 * * * date
# every two hours at the top of the hour
0 */2 * * * date
# every two hours from 11p.m. to 7a.m., and at 8a.m.
0 23-7/2,8 * * * date
# at 11:00 a.m. on the 4th and on every mon, tue, wed
0 11 4 * mon-wed date
# 4:00 a.m. on january 1st
0 4 1 jan * date
# once an hour, all output appended to log file
0 4 1 jan * date >>/var/log/messages 2>&1
HTH
Jamie...
|