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

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.

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