]> git.saurik.com Git - apple/launchd.git/blame - launchd/src/launchd.plist.5
launchd-106.tar.gz
[apple/launchd.git] / launchd / src / launchd.plist.5
CommitLineData
e91b9f68
A
1.Dd September 30, 2004
2.Dt launchd.plist 5
3.Os Darwin
4.Sh NAME
5.Nm launchd.plist
6.Nd System wide and per-user daemon/agent configuration files
7.Sh DESCRIPTION
8This document details the parameters that can be given to an XML property list that can be loaded into
9.Nm launchd
10with
11.Nm launchctl .
12.Sh EXPECTATIONS
13Daemons or agents managed by
14.Nm launchd
15are expected to behave certain ways.
16.Pp
17A daemon or agent launched by
18.Nm launchd
19MUST NOT do the following in the process directly launched by
20.Nm launchd :
21.Pp
22.Bl -bullet -offset indent -compact
23.It
24.Xr fork 2
25and have the parent process
26.Xr exit 3
27or
28.Xr _exit 2 .
29.It
30Call
31.Xr daemon 3
32.El
33.Pp
34A daemon or agent launched by
35.Nm launchd
36SHOULD NOT do the following as a part of their startup initialization:
37.Pp
38.Bl -bullet -offset indent -compact
39.It
40Setup the user ID or group ID.
41.It
42Setup the working directory.
43.It
44.Xr chroot 2
45.It
46.Xr setsid 2
47.It
48Close "stray" file descriptors.
49.It
50Change
51.Xr stdio 3
52to /dev/null.
53.It
54Setup resource limits with
55.Xr setrusage 2 .
56.It
57Setup priority with
58.Xr setpriority 2 .
59.It
60Ignore the SIGTERM signal.
61.El
62.Pp
63A daemon or agent launched by
64.Nm launchd
65SHOULD:
66.Pp
67.Bl -bullet -offset indent -compact
68.It
69Launch on demand given criteria specified in the XML property list.
70More information can be found in
71.Xr launch 3 .
72.It
73Catch the SIGTERM signal.
74.El
75.Sh XML PROPERTY LIST KEYS
76The follow keys can be used to describe the configuration details of your daemon or agent.
77Property lists files are expected to have their name end in ".plist" but that is not strictly required.
78.Pp
79.Bl -ohang
80.It Sy Label <string>
81This required key uniquely identifies the job to
82.Nm launchd .
83.It Sy Disabled <boolean>
84This optional key is used to disable your job. The default is false.
85.It Sy UserName <string>
86This optional key specifies the user to run the job as. The default is the user who submitted the job to
87.Nm launchd .
88.It Sy GroupName <string>
89This optional key specifies the user to run the job as. The default is the group of the user who submitted the job to
90.Nm launchd .
91.It Sy inetdCompatibility <dictionary>
92The presence of this key specifies that the daemon expects to be run as if it were launched from
93.Xr inetd 8 .
94.Bl -ohang -offset indent
95.It Sy Wait <boolean>
96This flag corresponds to the "wait" or "nowait" option of
97.Xr inetd 8 .
98.El
99.It Sy ProgramArguments <array of strings>
100This required key maps to the second argument of
101.Xr execvp 3 .
102.It Sy Program <string>
103This optional key maps to the first argument of
104.Xr execvp 3 .
105If this key is missing, then the first element of the array of strings provided to the ProgramArguments will be used instead.
106.It Sy OnDemand <boolean>
107This optional key is used to control whether your job is launched based on demand or to be kept continuously running. The default is true.
108.It Sy RunAtLoad <boolean>
109This optional key is used to control whether your job is launched once at the time the job is loaded. The default is false.
110.It Sy RootDirectory <string>
111This optional key is used to specific a directory to
112.Xr chroot 2
113to before running the job.
114.It Sy WorkingDirectory <string>
115This optional key is used to specific a directory to
116.Xr chdir 2
117to before running the job.
118.It Sy ServiceDescription <string>
119This optional key is used to specify a human readable description of the purpose of the job.
120.It Sy EnvironmentVariables <dictionary of strings>
121This optional key is used to specify additional environmental variables to be setup before running the job.
122.It Sy Umask <integer>
123This optional key specifies what value should be passed to
124.Xr umask 2
125before running the job.
126.It Sy ServiceIPC <boolean>
127This optional key specifies whether the job participates in advanced communication with
128.Nm launchd .
129The default is false.
130.It Sy TimeOut <integer>
131The recommended time out to pass to the job. If no value is specified, a default time out will be supplied by
132.Nm launchd
133for use by the job at check in time.
134.It Sy InitGroups <boolean>
135This optional key specifies whether the job should have
136.Xr initgroups 3
137should be called before running the job.
138The default is false.
139.It Sy WatchPaths <array of strings>
140This optional key causes the job to be started if any one of the listed paths are modified.
141.It Sy QueueDirectories <array of strings>
142Much like the WatchPaths option, this key will watch the paths for modifications. The difference being that the job will only be started if the path is a directory and the directory is not empty.
143.It Sy StartInterval <integer>
144This optional key causes the job to be started every N seconds.
145.It Sy StartCalendarInterval <dictionary of integers>
146This optional key causes the job to be started every calendar interval as specified. Missing arguments are considered to be wildcard. The semantics are much like
147.Xr crontab 5
148.
149.Bl -ohang -offset indent
150.It Sy Minute <integer>
151The minute on which this job will be run.
152.It Sy Hour <integer>
153The hour on which this job will be run.
154.It Sy Day <integer>
155The day on which this job will be run.
156.It Sy Weekday <integer>
157The weekday on which this job will be run (0 and 7 are Sunday).
158.It Sy Month <integer>
159The month on which this job will be run.
160.El
161.It Sy StandardOutPath <string>
162This optional key specifies what file should be used for data being sent to stdout when using
163.Xr stdio 3 .
164.It Sy StandardErrorPath <string>
165This optional key specifies what file should be used for data being sent to stderr when using
166.Xr stdio 3 .
167.It Sy Debug <boolean>
168This optional key specifies that
169.Nm launchd
170should adjust its log mask temporarily to LOG_DEBUG while dealing with this job.
171.Xr stdio 3 .
172.It Sy SoftResourceLimits <dictionary of integers>
173.It Sy HardResourceLimits <dictionary of integers>
174Resource limits to be imposed on the job. These adjust variables set with
175.Xr setrlimit 2 .
176The following keys apply:
177.Bl -ohang -offset indent
178.It Sy Core <integer>
179The largest size (in bytes) core file that may be created.
180.It Sy CPU <integer>
181The maximum amount of cpu time (in seconds) to be used by each process.
182.It Sy Data <integer>
183The maximum size (in bytes) of the data segment for a process; this defines how far a program may extend its break with the
184.Xr sbrk 2
185system call.
186.It Sy FileSize <integer>
187The largest size (in bytes) file that may be created.
188.It Sy MemoryLock <integer>
189The maximum size (in bytes) which a process may lock into memory using the
190.Xr mlock 2
191function.
192.It Sy NumberOfFiles <integer>
193The maximum number of open files for this process.
194.It Sy NumberOfProcesses <integer>
195The maximum number of simultaneous processes for this user id.
196.It Sy ResidentSetSize <integer>
197The maximum size (in bytes) to which a process's resident set size may grow.
198This imposes a limit on the amount of physical memory to be given to a process;
199if memory is tight, the system will prefer to take memory from processes that
200are exceeding their declared resident set size.
201.It Sy Stack <integer>
202The maximum size (in bytes) of the stack segment for a process; this defines
203how far a program's stack segment may be extended. Stack extension is
204performed automatically by the system.
205.El
206.It Sy Nice <integer>
207This optional key specifies what
208.Xr nice 3
209value should be applied to the daemon.
210.It Sy LowPriorityIO <boolean>
211This optional key specifies whether the kernel should consider this daemon to be low priority when doing file system I/O.
212.It Sy Sockets <dictionary of dictionaries...>
213This optional key is used to specify launch on demand sockets that can be used to let
214.Nm launchd
215know when to run the job. The job can check-in and get a copy of the file descriptors using APIs outlined in
216.Xr launch 3 .
217The paramters below are used as inputs to call
218.Xr getaddrinfo 3 .
219.Bl -ohang -offset indent
220.It Sy SockType <string>
221This optional key tells
222.Nm launchctl
223what type of socket to create. The default is "stream" and other valid values for this key
224are "dgram" and "seqpacket" respectively.
225.It Sy SockPassive <boolean>
226This optional key specifies whether
227.Xr listen 2
228or
229.Xr connect 2
230should be called on the created file descriptor. The default is true ("to listen").
231.It Sy SockNodeName <string>
232This optional key specifies the node to
233.Xr connect 2
234or
235.Xr bind 2
236to.
237.It Sy SockServiceName <string>
238This optional key specifies the service on the node to
239.Xr connect 2
240or
241.Xr bind 2
242to.
243.It Sy SockFamily <string>
244This optional key can be used to specifically request that "IPv4" or "IPv6" socket(s) be created.
245.It Sy SockProtocol <string>
246This optional key specifies the protocol to be passed to
247.Xr socket 2 .
248The only value understood by this key at the moment is "TCP".
249.It Sy SockPathName <string>
250This optional key implies SockFamily is set to "Unix". It specifies the path to
251.Xr connect 2
252or
253.Xr bind 2
254to.
255.It Sy Bonjour <boolean or string or array of strings>
256This optional key can be used to request that the service be registered with the
257.Xr mDNSResponder 8 .
258If the value is boolean, the service name is inferred from the SockServiceName.
259.El
260.El
261.Pp
262.Sh EXAMPLE XML PROPERTY LISTS
263.Pp
264The following XML Property List simply keeps "exampled" running continuously:
265.Pp
266.Dl <?xml version="1.0" encoding="UTF-8"?>
267.Dl <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
268.Dl <plist version="1.0">
269.Dl <dict>
270.Dl <key>Label</key>
271.Dl <string>com.example.exampled</string>
272.Dl <key>ProgramArguments</key>
273.Dl <array>
274.Dl <string>exampled</string>
275.Dl </array>
276.Dl <key>OnDemand</key>
277.Dl <false/>
278.Dl </dict>
279.Dl </plist>
280.Pp
281.Sh FILES
282.Bl -tag -width "/System/Library/LaunchDaemons" -compact
283.It Pa ~/Library/LaunchAgents
284Per-user agents provided by the user.
285.It Pa /Library/LaunchAgents
286Per-user agents provided by the administrator.
287.It Pa /Library/LaunchDaemons
288System wide daemons provided by the administrator.
289.It Pa /System/Library/LaunchAgents
290Mac OS X Per-user agents.
291.It Pa /System/Library/LaunchDaemons
292Mac OS X System wide daemons.
293.El
294.Sh SEE ALSO
295.Xr launchctl 1 ,
296.Xr launch 3 ,
297.Xr launchd 8