Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is crontab broken on OSX El Capitan?

Tags:

macos

cron

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

like image 365
dank Avatar asked Sep 25 '15 12:09

dank


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.

Does crontab work on Mac?

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 .

How do I know if crontab is running on my Mac?

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.


2 Answers

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.

like image 129
Jesús Carrera Avatar answered Sep 20 '22 07:09

Jesús Carrera


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.

like image 42
nickcoxdotme Avatar answered Sep 24 '22 07:09

nickcoxdotme