Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am trying to setup a cron on my mac, but it seems that it never finishes creating a crontab for my user. I open terminal and enter:

$ crontab -e 

Which returns this:

crontab: no crontab for jjmay - using an empty one




















~                                                                               
~                                                                               
~                                                                               
~                                                                               
~                                                                               
~                                                                               
~                                                                               
~                                                                               
~                                                                               
~                                                                               
~                                                                               
~                                                                               
~                                                                               
~                                                                               
~                                                                               
~                                                                               
~                                                                               
~                                                                               
~                                                                               
~                                                                               
~                                                                               
~                                                                               
"/tmp/crontab.rBdeP6yv1U" 0L, 0C

And then it waits there until I close out of the window, I have let it go for as long as 20min. I open another terminal window to check for the creation of my crontab and I get nothing.

$ crontab -l 
crontab: no crontab for jjmay

Any ideas on why I cannot create this, or if I can manually create my crontab so I can edit it?

share|improve this question
    
It's been awhile since I messed with crontab files in OS X, but my guess is that this: "/tmp/crontab.rBdeP6yv1U" 0L, 0C is indicating you're either not in the correct directory or don't have permissions to write to that directory. What is the directory that you are in when typing "crontab -e"? JDB –  JDB Oct 19 '10 at 19:53
    
@JDB thank you. I wasn't aware I would have to be in a specific dir., I was just in my default dir when I opened terminal, just my default User directory. /Users/<my_username>/ –  Jage Oct 20 '10 at 19:54

4 Answers 4

Closing the terminal window is not going to make the crontab save.

Since it's using vim to create the file, look up how to use VIM and go from there.

launchd is the (Apple) preferred method in 10.5 and 10.6, but you didn't ask about that, just how to get the crontab created.

share|improve this answer

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).

share|improve this answer

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
share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.