Friday, 5 October 2018

Correctly restarting syslog on Mac OS X

For some experimentation, I was recently looking at restarting syslog daemon. I expected it to be as simple as Linux system daemons. The init system of Mac appeared to be more like systemd in my initial searches. A few blogs instructed unload followed by load operation which sounded strange to me.

In systemd parlance, I expected unload operation to disable the daemon from starting up during initial booting. If you try to follow the process suggested in these blogs, you end up with an error stating "Operation not permitted while System Integrity Protection is engaged". This leaves two options:

  1. Disable System Integrity Protection
  2. Restart the system for every change in config
Of course, the answer is far too simple and none of these complexities need to handled. The right way of restarting the syslog daemon is as follows (using stop and start operations instead of unload and load):

sudo launchctl stop /System/Library/LaunchDaemons/
sudo launchctl start /System/Library/LaunchDaemons/