HomeHowTo › Start, Stop, Activate & Deactivate Services on Mac OS

Start, Stop, Activate & Deactivate Services on Mac OS

As for services (–> processes that are automatically launched on startup/login) Mac OS distinguishes between daemons and agents whereas daemons are system-wide services (–> one instance for all users) and agents are user-specific services. Both are managed by “launchd” which can be controlled using the “launchctl” command.

Services are saved as .plist files and can reside in one of the following folders (cf. launchd manpage):

~/Library/LaunchAgents Per-user agents provided by the user.
/Library/LaunchAgents Per-user agents provided by the administrator.
/Library/LaunchDaemons System-wide daemons provided by the administrator.
/System/Library/LaunchAgents Per-user agents provided by Mac OS X.
/System/Library/LaunchDaemons System-wide daemons provided by Mac OS X.

 

To enable or disable a daemon or agent, cd into the corresponding directory and then use one of the following commands (w-switch can be used if a problem occurs):

sudo launchctl unload [-w] com.foo.bar.plist
sudo launchctl load [-w] com.foo.bar.plist

 

With the following commands you can check which instances are running and start/stop them:

sudo launchctl list
sudo launchctl stop com.foo.bar
sudo launchctl start com.foo.bar

Note that a stopped service might automatically start up right again if it has not been unloaded.

Leave a Comment