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?
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 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.
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.
Just follow these steps:
crontab -e
.Type your cron job, for example:
30 * * * * /usr/bin/curl --silent --compressed http://example.com/crawlink.php
Press Esc to exit vim's insert mode.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With