Search code examples
macosvimcron

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


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?


Solution

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