launchctl

On this page 7

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 targetWho owns the jobsTypical content
systemroot, starts at bootLaunch daemons from /Library/LaunchDaemons
gui/UIDA logged-in user sessionLaunch agents with user interface access
user/UIDA user, including over SSHBackground agents without a login window
login/ASIDA specific audit sessionRare, session-bound helpers
pid/PIDA single processPrivate jobs created by an application
Common launchd domain targets

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 subcommandModern subcommandPractical difference
load -wbootstrap plus enableExplicit domain, clearer error codes
unload -wbootout plus disableRemoves the job from one named domain
startkickstart-k kills and restarts a running instance
stopkillSends a chosen signal such as SIGTERM
listprintShows full job state, triggers and exit status
Legacy verbs and their modern equivalents

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 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 mechanismPrimary roleRelation to launchctl
Launch agent plistDefines a per-user joblaunchctl loads it into a gui domain
Launch daemon plistDefines a system-wide joblaunchctl bootstraps it into the system domain
Login itemsOpens apps at login via System SettingsManaged by the user interface, not launchctl
cronClassic Unix time-based schedulerItself runs under launchd; launchd timers are preferred
pmsetPower and sleep schedulesComplements launchd jobs that need wake events
Where launchctl fits among system tools

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.plist registers a daemon in the system domain.
  • launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/com.example.sync.plist registers a per-user agent.
  • launchctl kickstart -k gui/$(id -u)/com.example.sync restarts a running job immediately.
  • launchctl print system/com.example.backup shows the last exit code, PID and triggers.
  • launchctl list | grep example gives a quick overview of loaded jobs and status codes.

The decision table below helps choose the right command for common administrative situations.

SituationRecommended commandReason
New plist just installedbootstrap into the correct domainRegisters the job without a reboot
Changed plist on diskbootout, then bootstraplaunchd caches the old definition
Job hangs or misbehaveskickstart -kForces a clean restart of the process
Job must never run againbootout plus disablePrevents reloading at the next boot
Troubleshooting a failureprint and the unified logShows exit status and launchd messages
Choosing a launchctl command

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.