launchd is the service management framework of macOS and the first process started in user space, running with process ID 1 and acting as the parent of every other process on a Mac. Among the core macOS fundamentals, it replaces the roles that traditional Unix systems split between init, cron, inetd and the startup scripts in a single program.
Apple introduced launchd in Mac OS X 10.4 Tiger in 2005. It reads property list configuration files, starts programs on demand when an event occurs, restarts them if they crash, and stops them when they are no longer needed. Administrators and developers interact with it through the launchctl command, while ordinary users mostly see its effects as login items and background services.
How launchd starts and supervises processes
launchd works by registering jobs first and launching programs later. When the XNU kernel finishes booting, it starts /sbin/launchd, which loads the job definitions found in system and user folders and creates the sockets, Mach ports and file watches those jobs request. The actual program usually stays stopped until a matching launch trigger arrives.
This design is called on-demand activation. A client that connects to a registered socket or Mach service does not need to know whether the server is running: launchd holds the connection, starts the program, and hands the endpoint over. The result is a faster boot, lower memory use and no fragile ordering of startup scripts, because dependencies are resolved by the communication channels themselves.
launchd also performs process supervision. It tracks the exit status of every job, applies throttling so that a crashing program is not relaunched more often than about once every 10 seconds by default, and can keep a job alive permanently when its configuration requests it. Because launchd is PID 1, a failure of launchd itself causes a kernel panic and an immediate restart.
Daemons, agents and their domains
launchd distinguishes jobs by who owns them and when they run. A daemon runs system-wide, usually as root or a dedicated service account, without any user interface. An agent runs on behalf of a logged-in user and may interact with the graphical session. The location of a job’s property list determines its type and its launchd domain.
The following table lists the standard job locations and their purpose.
| Folder | Job type | Runs as | Owner of the file |
|---|---|---|---|
| /System/Library/LaunchDaemons | System daemon | Root or service account | Apple, protected by SIP |
| /System/Library/LaunchAgents | System agent | Logged-in user | Apple, protected by SIP |
| /Library/LaunchDaemons | Third-party daemon | Root or specified user | Administrator or installer |
| /Library/LaunchAgents | Third-party agent for all users | Each logged-in user | Administrator or installer |
| ~/Library/LaunchAgents | Per-user agent | That user only | The user |
Modern launchctl addresses these contexts as domain targets: system for daemons, gui/<uid> for the graphical session of a user, and user/<uid> for background work tied to a user account. Choosing the wrong domain is a frequent reason why a job loads but cannot reach the window server or a user’s keychain.
Property list keys that define a job
Every launchd job is described by a property list file, in XML or binary form, whose keys tell launchd what to run and when. Only Label is strictly required, but a useful job also names the program and at least one trigger. Apple documents the complete key set in the launchd.plist manual page.
The keys below cover most real configurations.
| Key | Value type | Effect |
|---|---|---|
| Label | String | Unique job identifier, usually reverse DNS |
| ProgramArguments | Array of strings | Executable path and its arguments |
| RunAtLoad | Boolean | Starts the job as soon as it is loaded |
| KeepAlive | Boolean or dictionary | Restarts the job always or under conditions |
| StartInterval | Integer in seconds | Runs the job at a fixed interval |
| StartCalendarInterval | Dictionary | Runs the job at calendar times, like cron |
| WatchPaths | Array of paths | Runs the job when a file or folder changes |
| Sockets / MachServices | Dictionary | Starts the job when a client connects |
A missed calendar event behaves differently from cron: when a Mac is asleep at the scheduled time, launchd runs the job once after waking instead of skipping it. When the Mac is fully shut down, however, the event is not replayed.
launchd compared with other init and scheduling systems
launchd is best understood as a consolidation of several Unix tools into one event-driven supervisor. Its design later influenced systemd on Linux, which adopted socket activation and dependency-free parallel startup. The comparison below shows where the concepts overlap.
| Mechanism | Platform | Main role | Key difference from launchd |
|---|---|---|---|
| SysV init | Classic Unix, older Linux | Runs ordered startup scripts | No on-demand start or supervision |
| cron | Unix and Linux | Time-based scheduling | Skips jobs missed during sleep |
| inetd / xinetd | Unix and Linux | Starts servers on network connections | Network sockets only |
| systemd | Modern Linux | Init, supervision, socket activation | Unit files and explicit dependencies |
| Windows Service Control Manager | Windows | Starts and monitors services | Separate Task Scheduler for timing |
macOS still ships cron for compatibility, but Apple has recommended launchd for scheduled tasks for many years. XPC services inside applications are also launched and managed by launchd, which makes it the backbone of interprocess communication on Darwin.
Managing jobs with launchctl
Administrators control launchd through launchctl, which has two generations of subcommands. The legacy load and unload commands still work but are deprecated; the modern syntax since OS X 10.10 Yosemite uses bootstrap, bootout, enable, disable, kickstart and print together with a domain target.
| Task | Modern command | Notes |
|---|---|---|
| Load a daemon | sudo launchctl bootstrap system /Library/LaunchDaemons/x.plist | Requires root |
| Unload a user agent | launchctl bootout gui/501/com.example.job | Uses the job label |
| Restart a job now | launchctl kickstart -k gui/501/com.example.job | The -k flag kills the running instance |
| Inspect state | launchctl print system/com.example.job | Shows triggers, PID and last exit |
| Prevent loading | launchctl disable gui/501/com.example.job | Persists across restarts |
Since macOS 13 Ventura, applications can register helpers through the SMAppService interface, and the system notifies users about new background items in System Settings under Login Items. This gives users visibility into launchd jobs that were previously installed silently.
Security role, limitations and common mistakes
Because launchd can run any program automatically, launch agents and daemons are a classic persistence mechanism for malware. Security tools therefore monitor the LaunchAgents and LaunchDaemons folders, and System Integrity Protection prevents modification of Apple’s own jobs in the sealed system volume.
- Wrong file ownership or permissions: daemons in /Library/LaunchDaemons must be owned by root:wheel and not writable by others, or launchd refuses to load them.
- Programs that fork into the background: launchd expects the process to stay in the foreground; a self-daemonizing program looks like an exit and triggers restarts.
- Missing environment: jobs do not inherit a shell PATH, so scripts should use absolute paths or set EnvironmentVariables.
- Overly aggressive KeepAlive: an unconditional KeepAlive on a failing program wastes resources through repeated throttled restarts.
- Duplicate labels: two property lists with the same Label conflict, and only one job is registered.
launchd also offers no explicit dependency graph, so a job that needs a network volume or another service must handle the absence itself, for example by retrying or by using a WatchPaths trigger.
Understanding it simply
launchd is the building manager of a Mac. It is the first program that wakes up after the core of the system starts, and it is in charge of every other background program that follows.
Instead of keeping every service running all day, launchd keeps a list of who should be called and when. When a request arrives, a file changes or a scheduled time comes, it starts the right program, watches it, and restarts it if it stops unexpectedly. The key idea is starting work only when it is needed, which saves time and memory.
Applied in practice
A systems administrator at a design studio manages 40 Macs that must copy finished project files to a network server every night. Instead of a cron entry, the administrator deploys a single launchd daemon to /Library/LaunchDaemons with a Label of com.studio.nightlysync, a ProgramArguments entry pointing to a sync script, and a StartCalendarInterval of 23:30.
Some designers close their laptops before leaving, so those Macs are asleep at 23:30. Because launchd runs a missed calendar job after wake, every laptop completes its backup the next morning within minutes of opening the lid. The administrator checks the result remotely with launchctl print, which shows the last exit code of 0 on each machine, and fixes one failing Mac whose script lacked an absolute path to rsync.