4

I am maintaining some OS X 10.10 machines which require cron for various tasks (watchdog processes, /tmp cleaners, etc.). One of them has mysteriously stopped its cron daemon, and I can't seem to bring it back up short of manually running the /usr/sbin/cron command as root.

This isn't really maintainable; we distrust the stability of these machines enough that we have scheduled some staggered reboots in the crontab, so someone would have to ssh in and restart cron every time it reboots.

I have tried unloading and reloading the cron plist for launchd:

launchctl unload /System/Library/LaunchDaemons/com.vix.cron.plist
launchctl load /System/Library/LaunchDaemons/com.vix.cron.plist

I thought that would start it, but it did not. I then tried:

launchctl start /System/Library/LaunchDaemons/com.vix.cron.plist

But that also had no effect. There is still no cron in the process list, cron jobs aren't running, and launchctl list says - 0 com.vix.cron.

Moving away from cron to pure launchd is one way to get around this but it would require diverging our linux and mac code even further, and would require a lot of testing and frankly a lot more familiarity with launchd.

Being relatively new to OSX I have no idea where to go from here. How can I get cron to run on OSX 10.10, and to start on boot?


Update:

/etc/crontab exists as an empty file, but all users have their respective crontabs in /usr/lib/cron/tabs. A grep for cron in /var/log/system.log turns up no results other than the sudo cat invoked on the crontab files.

If I run this command once again:

launchctl load -w /System/Library/LaunchDaemons/com.vix.cron.plist

I get the error Operation already in progress.

1

launchd should start cron automatically if there are any contabs - either a global crontab at /etc/crontab or per-user tabs in /usr/lib/cron/tabs/*. Note that it does not support /etc/cron.d/, so if you're putting your job(s) there it won't do anything.

If you have at least one file in the relevant place and it's still not starting, check /var/log/system.log for error messages.

  • There are files in /usr/lib/cron/tabs and /etc/crontab exists. /etc/crontab is empty but the others have entries in them. A grep for cron in /var/log/system.log turns up no results other than the sudo cat invoked on the crontab files. Trying again with launchctl load -w /System/Library/LaunchDaemons/com.vix.cron.plist gives the error Operation already in progress – Score_Under Oct 20 '15 at 10:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.