Cron Task Scheduling

Published on March 01, 2010

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


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


Here are some cron jobs that I use regularly.

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

    7 10 3 * * /home/aruljohn/scripts/ > /var/logs/cleanup.log

  2. Run /home/aruljohn/scripts/ every 20 minutes everyday (and log to file).

    /20 * * * /home/aruljohn/scripts/ > /var/logs/monitor.log

  3. Run /home/aruljohn/scripts/ every 20 minutes everyday (with NO log).

    /20 * * * /home/aruljohn/scripts/ >/dev/null 2>&1

  4. Run /home/aruljohn/scripts/ every 20 minutes everyday (and send email).

    /20 * * * /home/aruljohn/scripts/

  5. Run everyday at 2am, 4am, 5am and 3pm

    • 2,4,5,15 * * * /home/aruljohn/scripts/

If you need a specific cron entry, you may contact me and I'll get back to you. No homework assignments please.

Related Posts

If you have any questions, please contact me at arulbOsutkNiqlzziyties@gNqmaizl.bkcom. You can also post questions in our Facebook group. Thank you.

Disclaimer: Our website is supported by our users. We sometimes earn affiliate links when you click through the affiliate links on our website.

Published on March 01, 2010