Apple - How do I restart the cron service on OSX?
The cron daemon is managed with launchctl.
If you insist on restarting it, you have to unload and load the respective launch daemon:
sudo launchctl unload /System/Library/LaunchDaemons/com.vix.cron.plist
sudo launchctl load /System/Library/LaunchDaemons/com.vix.cron.plist
But: adding or removing arbitrary crontabs shouldn't require a reload of the daemon to enable or disable them.
The above launch daemon plist contains a Watch Directory directive which detects (crontab) file creation and deletion or modified dates and "instructs" cron respectively.
From the cron
man page:
The cron utility is launched by launchd(8) when it sees the existence of /etc/crontab or files in /usr/lib/cron/tabs. There should be no need to start it manually. See /System/Library/LaunchDaemons/com.vix.cron.plist for details.
So, interstingly enough, cron
is launched by launchd
. However, according to man crontab
(Darwin note: Although cron(8) and crontab(5) are officially supported under Darwin, their functionality has been absorbed into launchd(8), which provides a more flexible way of automatically executing commands. See launchctl(1) for more information.)
So, cron
which is launched by launchd
, has been deprecated for launchd
. Using cron
is like wrapping bacon in bacon because you want bacon flavored bacon.
As far as restarting cron
, there is no need. Once it sees a crontab
file, it will automatically launch the job.
However, it's highly advisable that you start scheduling jobs using launchd.
sudo pkill -f cron
The LaunchDaemon has a keepalive section in it that will immediately restart it.