Launchd
Tasks
Get a list of running daemons:
launchctl list
Utilities
launchctl — Interfaces with launchd
launchctl
allows for detailed examination of launchd endpoints.- A domain manages the execution policy for a collection of services.
- A service may be thought of as a virtual process that is always available to be spawned in response to demand.
- Each service has a collection of end-points, and sending a message to one of those endpoints will cause the service to launch on demand.
- Domains advertise these endpoints in a shared namespace and may be thought of as synonymous with Mach bootstrap subsets.
bootstrap | bootout domain-target [service-path service-path2 …] | service-target
Bootstraps or removes domains and services. When service arguments are present, bootstraps and correspondingly removes their definitions into the domain. Services may be specified as a series of paths or a service identifier. Paths may point to XPC service bundles,
launchd.plist(5) s, or a directories containing a collection of either.
sudo launchctl bootstrap system /System/Library/LaunchDaemons/ssh.plist
enable | disable service-target
Enables or disables the service in the requested domain.
launchctl enable system/org.net-snmp.snmpd
sudo launchctl enable system/com.openssh.sshd
kickstart [-kp] service-target
Instructs launchd to run the specified service immediately, regardless of its configured launch conditions.
-k | If the service is already running, kill the running instance before restarting the service. |
-p | Upon success, print the PID of the new process or the already-running process to stdout. |
launchctl kickstart -k system/org.net-snmp.snmpd
print domain-target | service-target
Prints information about the specified service or domain.
launchctl print system/org.net-snmp.snmpd
sudo launchctl print system/com.openssh.sshd
Concepts
“Domain” can be:
`system/<service>`
`user/<UID>`
`pid/<PID>`
`session/<asid>`
Deprecated
- -w Overrides the Disabled key and sets it to false or true for the load and unload subcommands respectively. In previous versions, this option would modify the configuration file. Now the state of the Disabled key is stored elsewhere on- disk in a location that may not be directly manipulated by any process other than launchd.
- -F Force the loading or unloading of the plist. Ignore the Disabled key.
Get a list of running daemons:
launchtl list
start/stop/restart a daemon/service:
sudo launchctl unload /System/Library/LaunchDaemons/org.net-snmp.snmpd.plist
sudo launchctl load -w /System/Library/LaunchDaemons/org.net-snmp.snmpd.plist
-w Overrides the Disabled key and sets it to false or true for the load and unload subcommands respectively