Notes: Cron Jobs (Scheduled Tasks) in Mac OS X

These are my notes on how to create cron jobs in Mac OS X. Linux users are already familiar with cron. Cron jobs in Windows are called Scheduled Tasks.

First, I set the default editor to be nano. I like the simplicity of nano compared to the default vim editor. It is more humane!!

Edit the .bash_profile script

$ nano ~/.bash_profile

Add the following line

export EDITOR=”nano”

Save, exit and reload the bash script

$ source ~/.bash_profile

Open the cron table

$ crontab -e

Add the following lines (for example)

MAILTO=””
*/5 9-15 * * *  <command>

Save and exit

That will run <command> every 5 minutes, from 9am to 3:55pm, daily. Of course you should change <command> with a real Mac OS X command that you need to run.

Watch out for mails in:

/var/mail/darwin

If you wish to receive emails every time the cron job executes, change the MAILTO line to:

MAILTO=”your-email-address”

It worked!

Bookmark the permalink.

One Comment

  1. Eduard Vincent Aban

    Nice one!

Leave a Reply

Your email address will not be published. Required fields are marked *