Script management with launchd
launchd process is used by macOS 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:
Apple-supplied system daemons
Apple-supplied agents that apply to all users on a per-user basis
Third-party system daemons
Third-party agents that apply to all users on a per-user basis
Third-party agents that apply only to the logged-in user
For more information about
launchd, see the
launchctl man pages. Also see Technical Note TN2083: Daemons and Agents in the macOS Developer Library.