Set Crontab in Apple Macintosh OS X (Lion)

(Or After CronniX... what now?)

(Note: I believe the following is correct, but use at your own risk... usual disclaimers apply!)

If you have a shell script (or a program) that must be run as root AND if you were using the CronniX utility you have a problem because Cronnix uses Rosetta to CREATE root cron jobs and Lion won't run Rosetta. (CronniX seems to be OK to create "user" (non-root) cron jobs, but I have not checked it carefully.)

I always thought that CronniX was a substitute for cron. WRONG. It is just a front-end so you don't have to mess with the dumb syntax of a crontab file. Well, the front-end will not work on the root contrab file. It won't open it. You get a cryptic message from Lion. I don't know why Cronnix uses Rosetta and lots of people are not happy about it. From what I gather the program is no longer supported by the developer.

So lets assume you already have a crontab file for root. How will you know? Go to and enter:

sudo crontab -l
(That is a lower case "ell" as in "list," not the number"one".)

(You use sudo because that puts you as the "root" user (for one command) and the system knows to open the crontab for the user who executed the command. If you want to see your user (your own) crontab leave out the "sudo" prefix.)

Password: (password for your Mac)

And you get:

33 08 * * * /Users/al/Documents/wget/
0 22 * * * /Users/al/Documents/wget/
30 17 * * * /Users/al/Documents/wget/

If you don't have one, no matter. I believe (not sure) that next command will either edit one or create one... but I'll assume you have one because you had CronniX which created one for you.

Enter in terminal: sudo EDITOR=nano crontab -u root -e
(note the upper case. Just copy and paste what I have... don't ask questions!)

(I changed the editor to "nano" as it would default to "vim," which is a nightmare to use if not used to it. This is a one-time change, not permanent. If nano does not work, use pico... same program.)

You will get a character-based text editor where you can make changes to your cron file or add new jobs. There are a ton of tutorials on the net on the format of a crontab so Google for those to find what is what with the numbers and *'s (which set the time/date) and how to write the script name or program you want run. You should see something like this (but with more spaces:)

GNU nano 2.0.6 File: /tmp/crontab.LeSWHA8w0W

33 08 * * * /Users/al/Documents/wget/
0 22 * * * /Users/al/Documents/wget/
30 17 * * * /Users/al/Documents/wget/

[ Read 3 lines ]
^G Get Help ^O WriteOut ^R Read File ^Y Prev Page ^K Cut Text ^C Cur Pos
^X Exit ^J Justify ^W Where Is ^V Next Page ^U UnCut Text ^T To Spell

Use the arrow keys to move around the file and enter the info. There are a number of tutorials on Nano (same as Pico on the Mac) so you can look at those to see how to do what you want in this arcane text editor.

When done, enter Ctl-o (lower case... that means hold the Control key (no, not the command key or alt key, but the one that says "control" on it) and then press the "o" key... the letter "o" not zero!) This means "write it OUT... "o" for out! I would have used a "w" for "write.")

At bottom it will ask you to confirm with the name of a file with strange letters in it. Just press the Enter key and it will say how many lines were written. Then press Ctl-X (lower case) to exit

And that's it. There is nothing else you need to do. Cron wakes up each minute and checks this file to see if it should run anything. Of course, if you made an error in entering the stuff, your job won't work. As I say, there are tons of tutorials on cron so look at one of the to see how to detect errors, debug, etc. Most often it is an error in the script, not in how you entered the crontab stuff.

Usually if cron has a problem it sends you "system" email but I think Apple has that turned off. You can try, in terminal:

alan-cantons-computer-imac1:~ al$ mail
No mail for al

To check for root mail:

alan-cantons-computer-imac1:~ al$ sudo mail
No mail for root

Thus, I'm not sure how Apple's cron communicates with you if there is an error. If you find out, write me and let me know.

If you want to reach me you can go to Scroll down and there is a "email" link on the right side of the screen. Use that to email me. Please don't call!

Alan N. Canton

A.N. Canton Insurance Services
Fair Oaks, CA