Why I've got no crontab entry on OS X when using vim?

mollerhoj picture mollerhoj · Mar 13, 2013 · Viewed 119.6k times · Source

I would like to use cron on my Mac. I choose it over launchd, because I want to be able to use my new knowledge on Linux as well. However, I cannot seem to get the crontab -e command to work. It fires up vim, I enter my test job:

0-59 * * * * mollerhoj3 echo "Hello World"

But after saving and quitting (:wq),

crontab -l

says:

No crontab for mollerhoj3

What am I doing wrong?

Answer

Cao Manh Dat picture Cao Manh Dat · May 24, 2013

Just follow these steps:

  1. In Terminal: crontab -e.
  2. Press i to go into vim's insert mode.
  3. Type your cron job, for example:

    30 * * * * /usr/bin/curl --silent --compressed http://example.com/crawlink.php
    
  4. Press Esc to exit vim's insert mode.

  5. Type ZZ to exit vim (must be capital letters).
  6. You should see the following message: crontab: installing new crontab. You can verify the crontab file by using crontab -l.

Note however that this might not work depending on the content of your ~/.vimrc file.