Mac crontab is never created

Solution 1:

This isn't about the editor, it's about user permissions. First become root:

sudo su -

Then edit the crontab for the proper user:

crontab -u username -e

After saving the file, can verify that it saved properly by running this:

crontab -u username -l

Solution 2:

I have encounter this problem just now. While trying to solve the problem, I was referred here form Google. Anyway, here is how I solved it.

use

crontab -e

which you have done right.

Press 'i' to insert your cronjob. For example,

1 * * * * /Users/Wong/Documents/abc.command

~

Remember to press return after the line. If you don't press return it will be like this

1 * * * * /Users/Wong/Documents/abc.command

Press ESC and type in :wq to save and exit the file. It should says "crontab: installing new crontab"

I realised that if you don't press return after your line, it won't save the whole thing.

Hope it helps.

Solution 3:

The window it's showing is a vi editor. On traditional unix systems, vi is the default editor; it looks like Mac OS X has kept that tradition.

Set the EDITOR and VISUAL environment variables to the name (full path, if it's not in $PATH) of your favorite editor. E.g.

export EDITOR=emacs VISUAL=emacs
crontab -e

This setting should go into your ~/.profile (assuming that Mac OS X does read that file when you log in; if there is an OSX way of defining environment variables for a whole session, you can define them there).