launchctl is the command-line interface to launchd, the service manager that starts as process 1 on macOS and supervises every background job on the system. Administrators and developers use it in Terminal to load, unload, start, stop, enable, disable and inspect launch agents and launch daemons without restarting the Mac.
Within the Terminal & scripting toolkit, launchctl sits next to defaults, osascript and pmset as one of the tools that control how the operating system behaves behind the scenes. It does not define jobs itself: the property list files in the LaunchAgents and LaunchDaemons folders describe each job, and launchctl tells launchd what to do with them.
How launchctl talks to launchd
launchctl works by sending requests over XPC to launchd, which owns the actual job state. When a command such as launchctl bootstrap runs, launchd reads the job’s property list, validates keys such as Label and ProgramArguments, and registers the job in a domain. The tool itself keeps no state, so every answer it prints comes directly from launchd.
A domain is the scope in which a job lives. The system domain holds daemons that run as root regardless of who is logged in, while each logged-in user has a gui domain for agents that may display windows and a user domain for background work. Commands address domains with service targets such as system/com.example.backup or gui/501/com.example.sync, where 501 is the user ID.
The table below lists the domain targets that appear most often in modern launchctl commands.
| Domain target | Who owns the jobs | Typical content |
|---|---|---|
| system | root, starts at boot | Launch daemons from /Library/LaunchDaemons |
| gui/UID | A logged-in user session | Launch agents with user interface access |
| user/UID | A user, including over SSH | Background agents without a login window |
| login/ASID | A specific audit session | Rare, session-bound helpers |
| pid/PID | A single process | Private jobs created by an application |
Legacy and modern launchctl subcommands
launchctl has two generations of subcommands. The older load, unload, start and stop verbs date from early macOS releases and still work for compatibility, but Apple marked them as legacy in OS X Yosemite and introduced domain-aware verbs that report errors more precisely and behave predictably over SSH.
The comparison below maps each legacy verb to its modern replacement and notes the practical difference.
| Legacy subcommand | Modern subcommand | Practical difference |
|---|---|---|
load -w | bootstrap plus enable | Explicit domain, clearer error codes |
unload -w | bootout plus disable | Removes the job from one named domain |
start | kickstart | -k kills and restarts a running instance |
stop | kill | Sends a chosen signal such as SIGTERM |
list | print | Shows full job state, triggers and exit status |
Disabled state persists outside the job file: launchctl disable records an override in a launchd database, so a job stays off after reboot even if its property list still says otherwise. This override is a frequent source of confusion when a job silently refuses to load.
launchctl compared with related macOS tools
launchctl is the control layer, not the job definition. A launch agent or launch daemon is the plist that describes what to run and when; launchctl activates, queries or removes that definition. Several neighboring tools overlap with it in specific situations, and the following table clarifies the division of labor.
| Tool or mechanism | Primary role | Relation to launchctl |
|---|---|---|
| Launch agent plist | Defines a per-user job | launchctl loads it into a gui domain |
| Launch daemon plist | Defines a system-wide job | launchctl bootstraps it into the system domain |
| Login items | Opens apps at login via System Settings | Managed by the user interface, not launchctl |
| cron | Classic Unix time-based scheduler | Itself runs under launchd; launchd timers are preferred |
| pmset | Power and sleep schedules | Complements launchd jobs that need wake events |
Apple recommends launchd calendar intervals over cron because launchd runs a missed job when the Mac wakes from sleep, whereas cron simply skips a run that falls inside a sleep period.
Practical use and essential commands
Day-to-day work with launchctl follows a short cycle: validate the plist, bootstrap the job, verify its state and read its logs. Validation with plutil -lint catches syntax errors before launchd rejects the file, and launchctl print confirms whether the job is running, waiting for a trigger or exiting with an error.
sudo launchctl bootstrap system /Library/LaunchDaemons/com.example.backup.plistregisters a daemon in the system domain.launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/com.example.sync.plistregisters a per-user agent.launchctl kickstart -k gui/$(id -u)/com.example.syncrestarts a running job immediately.launchctl print system/com.example.backupshows the last exit code, PID and triggers.launchctl list | grep examplegives a quick overview of loaded jobs and status codes.
The decision table below helps choose the right command for common administrative situations.
| Situation | Recommended command | Reason |
|---|---|---|
| New plist just installed | bootstrap into the correct domain | Registers the job without a reboot |
| Changed plist on disk | bootout, then bootstrap | launchd caches the old definition |
| Job hangs or misbehaves | kickstart -k | Forces a clean restart of the process |
| Job must never run again | bootout plus disable | Prevents reloading at the next boot |
| Troubleshooting a failure | print and the unified log | Shows exit status and launchd messages |
Limitations and common mistakes
Most launchctl problems come from wrong domains, wrong permissions or stale definitions. launchd refuses any plist in the system folders that is not owned by root with mode 644, and it reports the refusal only with a terse error such as “Bootstrap failed: 5: Input/output error”.
- Editing a loaded plist has no effect until the job is booted out and bootstrapped again.
- Running agent commands with sudo targets the root user’s domain instead of the logged-in user.
- System Integrity Protection blocks changes to Apple jobs in /System/Library, so those cannot be disabled with launchctl.
- Exit code 78 often means a configuration error, while 126 or 127 points to a missing or non-executable program.
- Background item notifications in recent macOS versions alert the user whenever a new agent or daemon is added.
Managed Macs add one more consideration: an MDM solution can deploy and lock launchd jobs through configuration profiles, and local launchctl changes may be reverted at the next check-in.
In plain words
Every Mac runs many small helper programs in the background: backup tools, update checkers, sync services. A built-in manager called launchd decides when each one starts and stops. launchctl is the remote control for that manager. You type a command in Terminal, and launchd starts, stops or reports on a helper.
Think of launchd as a building superintendent and the plist files as job cards pinned to a board. launchctl is how you tell the superintendent to pick up a new card, throw one away, or explain why a job did not get done. The key point is that launchctl manages jobs, it does not describe them.
A real-world example
A small design studio keeps project files on a network share and wants each workstation to copy finished renders to that share every night at 1:30. The administrator writes a script and a plist named com.studio.rendersync with a StartCalendarInterval of hour 1, minute 30, places it in /Library/LaunchDaemons, sets ownership to root:wheel and mode 644, and runs sudo launchctl bootstrap system with the file path.
The next morning one Mac shows no copied files. sudo launchctl print system/com.studio.rendersync reports last exit code 127, which reveals a typo in the script path. After correcting the plist, the administrator runs bootout and bootstrap again, then kickstart to test immediately. The job completes in under two minutes and runs reliably every night after that, including on nights when the Mac was asleep at 1:30 and woke later.