Reputation: 851
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).
Upvotes: 29
Views: 22347
Reputation: 1461
If you type cd /usr/lib/cron
then ls
you'll see you have at.deny
and cron.deny
, but no at.allow
or cron.allow
.
Run sudo nano cron.allow
and enter your usernames one per line.
Create a copy for at.allow
as such sudo cp cron.allow at.allow
.
I created those two file and it started running.
Upvotes: 5
Reputation: 8143
For Mojave, Full Disk Access prevents you from changing system files (which includes privacy related data as well as system configuration like the crontabs).
To enable access:
Upvotes: 12
Reputation: 338
cron will completely skip any jobs while the machine is asleep. Try checking your energy saver settings (see below).
launchd (Apple's recommended alternative) also doesn't run while the machine is asleep, but won't skip jobs. Instead the jobs run when the machine awakens.
Upvotes: 4
Reputation: 81
On a MacBook, using El Capitan (10.11.5), "cron" still works just fine.
"/usr/lib/cron.deny" is the default (lists "Guest" only), and there is no "cron.allow". Don't recall doing any customisations to make it work (no init/config files mods, no chmod's, no file/dir creates/deletes, etc.).
(Was using 10.6.* until that MacBook died in April. Began using 10.11 in mid-May, restored my crontab after the 10.11.5 update (?late May?). So don't know if cron was working under 10.11, or re-enabled by the 10.11.5 update.)
Try this simple test: "crontab -e", then "*/5 * * * * date >> /tmp/z.date". Should see a new date every five minutes.
If that works, try "*/5 * * * * env >> /tmp/z.date.1", and check your environment. E.g., the default PATH is quite short.
Btw, "at" is a batch job queue. "at", "batch", and "cron" are often grouped together, as they do variations of the same thing.
Upvotes: 8
Reputation: 6707
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.
Upvotes: 17
Reputation: 11425
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.
Upvotes: 18