Script management with launchd

OS X Yosemite uses the launchd process to manage daemons and agents, and you can use it to run your shell scripts. You don’t interact with launchd directly. Instead you use the launchctl tool to load or unload launchd daemons and agents.

During system startup, launchd is the first process the kernel runs to set up the computer. If you want your shell script to be run as a daemon, it should be started by launchd. Other mechanisms for starting daemons and agents are subject to removal at Apple’s discretion.

You can get an idea of the various daemons and agents managed by launchd by looking at the following configuration files:

Folder

Usage

/System/Library/LaunchDaemons/

Apple-supplied system daemons

/System/Library/LaunchAgents/

Apple-supplied agents that apply to all users on a per-user basis

/Library/LaunchDaemons/

Third-party system daemons

/Library/LaunchAgents/

Third-party agents that apply to all users on a per-user basis

~/Library/LaunchAgents/

Third-party agents that apply only to the logged-in user

For more information about launchd, see the launchd and launchctl man pages. Also see Technical Note TN2083: Daemons and Agents in the OS X Developer Library.