Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

vim

macos

cron

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?

like image 709
mollerhoj Avatar asked Mar 13 '13 20:03

mollerhoj


People also ask

Why is crontab not running on Mac?

It turns out to be a permission issue brought by the newly introduced security features, thus it's not a “bUG”. To solve it, just add your cron location (in most cases /usr/sbin/cron ) to the Full Disk Access lists located at System Preferences.

Why is my crontab entry not running?

Why is crontab not working in your system? Crontab might fail for a variety of reasons: The first reason is that your cron daemon might not be working for any reason, resulting in your crontab failing. There also exists a possibility that your system's environment variables are not settled correctly.

Where is crontab file OSX?

In Mac OS X Lion the user crontabs are stored in /var/at/tabs . In the past they were located in /var/cron/tabs . You should use crontab -e to interact with these in general, but knowing the location is useful for when you want to restore them from a backup of your disk, or something similar.


1 Answers

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.

like image 193
Cao Manh Dat Avatar answered Oct 04 '22 20:10

Cao Manh Dat