lots of tech info here

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:

export EDITOR=/usr/local/bin/emacs

Commands

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:

>/dev/null 2>&1

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.

  1. Run script /home/aruljohn/scripts/cleanup.sh on the 3rd of every month at 10:07 AM.

    7 10 3 * * /home/aruljohn/scripts/cleanup.sh > /var/logs/cleanup.log
    
  2. Run /home/aruljohn/scripts/monitor.sh every 20 minutes everyday (and log to file).

    */20 * * * * /home/aruljohn/scripts/monitor.sh > /var/logs/monitor.log
    
  3. Run /home/aruljohn/scripts/monitor.sh every 20 minutes everyday (with NO log).

    */20 * * * * /home/aruljohn/scripts/monitor.sh >/dev/null 2>&1
    
  4. Run /home/aruljohn/scripts/monitor.sh every 20 minutes everyday (and send email).

    */20 * * * * /home/aruljohn/scripts/monitor.sh
    
  5. Run check.pl everyday 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

TAGS: cron

If you liked this article, subscribe to our Feed, follow us on Twitter (@aruljohn) and/or join our Facebook Page.

Share this with Others

Subscribe

Tags