Script management with launchd in Terminal on Mac
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 command 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 configuration files in the following folders:
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