Question. Is cron
supposed to work in OSX El Capitan?
Background. I've used crontab for years on OSX, but with El Capitan it seems not to work. I added my username to /usr/lib/cron/cron.allow
and even rebooted the machine, but still my cron jobs don't do anything, nor do they mail me with errors. The manpages suggest Apple doesn't want people using cron, but they don't say it is nonfunctional (yet).
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.
On the Mac, we can use crontab -e to open an editor in Vim which will allow us to enter the following. Note: if you want to use another editor you are familiar with, you will need to update your run command file to change the editor ie if you use Bash, add export EDITOR=/usr/bin/nano to your .
To see your active cron jobs, you can use the crontab -l command. If you want to, for instance, run a Python script using a cron job, you'll have to deal with some added complexity. The way you should set this up is by having two scripts — the Python script and an executable shell script that runs the Python script.
It seems to work for me, but I think you need to specify the editor:
env EDITOR=nano crontab -e
Add your crons, and then save the file with the name and location given. In my case it's a file in /tmp/crontab.xxxx
.
Then if you do crontab -l
you should see your crons.
This is another answer for anyone that finds this via Google. There aren't many results.
For me, somehow /usr/lib/cron
was symlinked to /var/at
(which I'd never even heard of…), and /var/at
had a cron.allow
file, which my username wasn't in, so running sudo vi /var/at/cron.allow
and adding my username (somehow redirecting echo
into that file didn't work…) fixed it.
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