Cron Task Scheduling
Cron is a Unix utility that allows processes/tasks to be run in the background at regular intervals or specific times.
To create or edit a cron, first set the EDITOR environment variable. I like emacs, so:
crontab -e Edit crontab file crontab -l List crontab contents crontab -r Remove crontab contents
To disable email, add this to the end of the crontab entry:
Syntax of crontab line
MINUTE HOUR DAY-OF-MONTH (1-31) MONTH (1-12) DAY-OF-WEEK (0-6) COMMAND
Here are some cron jobs that I use regularly.
/home/aruljohn/scripts/cleanup.shon the 3rd of every month at 10:07 AM.
7 10 3 * * /home/aruljohn/scripts/cleanup.sh > /var/logs/cleanup.log
/home/aruljohn/scripts/monitor.shevery 20 minutes everyday (and log to file).
*/20 * * * * /home/aruljohn/scripts/monitor.sh > /var/logs/monitor.log
/home/aruljohn/scripts/monitor.shevery 20 minutes everyday (with NO log).
*/20 * * * * /home/aruljohn/scripts/monitor.sh >/dev/null 2>&1
/home/aruljohn/scripts/monitor.shevery 20 minutes everyday (and send email).
*/20 * * * * /home/aruljohn/scripts/monitor.sh
check.pleveryday at 2am, 4am, 5am and 3pm
* 2,4,5,15 * * * /home/aruljohn/scripts/check.pl
If you need a specific cron entry, you may contact me and I'll get back to you. No homework assignments please.
Posted on 01 Mar 2010
If you liked this article, subscribe to our Feed, follow us on Twitter (@aruljohn) and/or join our Facebook Page.