System-wide/per-user daemon/agent configuration files
Parameters given to an XML property list to be loaded into
/Library/LaunchAgents , /Library/LaunchDaemons, ~/Library/LaunchAgents
A daemon or agent launched by launchd
in the process directly launched by launchd MUST NOT
as part of their startup initialization SHOULD NOT
- fork and have the parent process exit or _exit.
- Call daemon
- Setup the user ID or group ID.
- Setup the working directory.
- Close "stray" file descriptors.
- Change stdio to /dev/null.
- Setup resource limits with setrusage.
- Setup priority with setpriority.
- Ignore the SIGTERM signal.
- Launch on demand given criteria specified in the XML property list. More information can be
found in launch.
- Catch the SIGTERM signal.
XML PROPERTY LIST KEYS
Property lists filenames end in
label, ProgramArguments entries are required.
| uniquely identifies the job to |
|first argument of execvp(program). |
If omitted the first element of the of
array of strings will be used.
ProgramArguments array of strings
|second argument to |
execvp(array of pointers to args).
Disabled T | F
|default false. Depreacted see |
| user to run the job. default user who submitted the job to launchd.
OnDemand T | F
| launched on demand (default) or|
kept continuously running
RunAtLoad T | F
|launched once when the job is loaded. default false.
HopefullyStartsSerially T | F
not used as of leopard
| exit earlier during system shutdown ref |
HopefullyExitsFirst T | F
| exit earlier during system shutdown ref|
used by: mDNSResponder,
depricatedSystemStarter starts rc.local and rc.shutdown.local
HopefullyExitsLast T | F
exit in a second wave during system-shutdown used by:
chroot dir before running the job.
cd dir before running the job.
| purpose of the job.
EnvironmentVariables dictionary of strings
| set before running the job.
|this daemon expects to be run as if it were launched from inetd.|
This is incompatible with
ServiceIPC T | F
| if the job participates in advanced communication with |
launchd. default is false.
|seconds before restarting (zero will be complained about and 10 used)
|Passed to the job. If no value is specified, a default time out will be supplied by launchd for use by the job at check in time.
InitGroups T | F
| have |
initgroups be called before running the job. The default is false.
AbandonProcessGroup T | F
WatchPaths array of strings
| job started if any one of the listed paths are modified.
QueueDirectories array of strings
| job started if the path modified is a directory and the directory is not empty.
| job started every N seconds. |
If the system is asleep, the job will be started the next time the computer wakes up.
If multiple intervals transpire before the computer is woken, those events will be coalesced into one event upon wake from sleep.
StartCalendarInterval dictionary of integers
|job is started every calendar interval . |
Missing arguments are considered to be wildcard, i.e. every.
The semantics are like crontab.
cron which skips job invocations when the computer is asleep,
launchd will start the job the next time the computer wakes up!
If multiple intervals transpire before the computer is woken, those events will be coalesced into one event
Minute integer Hour integer Day integer Weekday integer The weekday on which this job will be run (0 and 7 are Sunday).
|used by alf |
Debug T | F
|launchd should adjust its log mask temporarily to LOG_DEBUG while dealing with this job.
SoftResourceLimits dictionary of integers
HardResourceLimits dictionary of integers
| Resource limits to be imposed on the job. These adjust variables set with setrlimit. |
|largest size (in bytes) core file that may be created.
|maximum cpu seconds to be used by each process.
|maximum bytes of the data segment for a process; this defines how far a program may extend its break with the sbrk system call.
| largest size (in bytes) file that may be created.
|maximum bytes which a process may lock into memory using mlock .
|maximum number of open files for this process.
| maximum number of simultaneous processes for this user id.
|maximum bytes to which a process's resident set size may grow. This imposes a limit on the amount of physical memory to be given to a process; if memory is tight, the system will prefer to take memory from processes that are exceeding their declared resident set size.
|maximum bytes of the stack segment for a process; this defines how far a program's stack segment may be extended. Stack extension is performed automatically by the system.
|dictionary of PathStates (?) See |
| nice value applied to the daemon.
LowPriorityIO T | F
|daemon to be low priority when doing file system I/O.
Wait T | F
|corresponds to |
nowait of inetd.
|dictionary of boolean agents or daemons required
Sockets dictionary of dictionaries... OR
dictionary of array of dictionaries...
| on demand sockets that can be used to let launchd know when to run the job. |
The job can check-in and get a copy of the file descriptors using APIs outlined in launch.
The keys of the top level Sockets dictionary are meant for the application developer to use to
differentiate different which descriptors correspond to which application
level protocols (e.g. http vs. ftp vs. DNS...).
At check in time, the value of each Sockets dictionary
key will be an array of descriptors. Daemon/Agent authors should consider all descriptors of a given
key to be to be effectively equivalent, even though each file descriptor likely represents a different
networking protocol which conforms to the criteria specified in the job configuration file.
used as inputs to call getaddrinfo.
SockPassive T | F
| if listen should be called on the created file descriptor. default true ("to listen"), otherwise connect .
|node to connect or bind to.
|service on the node to connect or bind to.
|IPv4 or IPv6 socket(s) be created.
| implies |
SockFamily is set to "Unix". It specifies the path to connect or bind to.
| mode of the socket in decimal.
|Bonjour boolean or |
array of strings
| can be used to request that the service be registered with |
If the value is boolean, the service name is inferred from
|MulticastGroup string ||used to request that the datagram socket join a multicast group.|
If the value is a hostname, then getaddrinfo will be used to join the correct multicast address for a given socket family.
If IPv4 or IPv6 address is given,
SockFamily is required.
|Umask integer|| set umask before running the job.
EXAMPLE XML PROPERTY LISTS
The following XML Property List simply keeps "exampled" running continuously:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC -//Apple Computer//DTD PLIST 1.0//EN
<key>ProgramArguments</key> <array> <string>exampled</string> </array>
Apple developer docs
Also lingoneditor for plists,
pl converts xml to key=value format
plistbuddy binary editor