Home

LaunchAgents

LaunchAgents are a type of job definition used by macOS launchd to run programs or scripts automatically in a user’s context. They enable per-user automation and background tasks, complementing LaunchDaemons, which run with elevated privileges for system-wide services.

A LaunchAgent is a property list (plist) file that must be well formed and placed in specific

The plist specifies at least a Label to identify the job and either a Program (the executable

Management and usage often involve the launchctl command. Users can load or unload a LaunchAgent with appropriate

Security and best practices emphasize using minimal privileges, placing system-wide agents in the correct directory with

locations.
The
common
locations
are
per-user:
~/Library/LaunchAgents,
and
system-wide:
/Library/LaunchAgents.
LaunchDaemons,
in
contrast,
live
in
/Library/LaunchDaemons
and
run
as
root.
When
a
user
logs
in
or
when
a
system
policy
loads
the
agent,
launchd
reads
the
plist
and
starts
the
configured
program.
path)
or
ProgramArguments
(an
array
of
the
program
and
its
arguments).
Optional
keys
control
behavior,
such
as
RunAtLoad
(start
when
the
plist
is
loaded),
StartInterval
(time
between
runs
in
seconds),
and
StartCalendarInterval
(specific
times
or
dates).
KeepAlive
can
cause
the
job
to
respawn
if
it
exits,
while
StandardOutPath
and
StandardErrorPath
redirect
logs.
Other
common
keys
include
WorkingDirectory
and
EnvironmentVariables.
permissions,
and
list
active
jobs
with
launchctl
list.
For
per-user
agents,
simply
placing
the
plist
in
the
user’s
LaunchAgents
directory
will
typically
load
at
login;
system-wide
agents
may
require
additional
steps
or
policy
configurations.
appropriate
ownership,
and
directing
output
to
log
files.
Avoid
interactive
prompts
and
test
changes
to
ensure
stability
and
expected
behavior.