]>
Commit | Line | Data |
---|---|---|
d1ab0ca0 LP |
1 | <?xml version='1.0'?> <!--*-nxml-*--> |
2 | <?xml-stylesheet type="text/xsl" href="http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl"?> | |
3 | <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" | |
4 | "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"> | |
5 | ||
6 | <!-- | |
7 | This file is part of systemd. | |
8 | ||
9 | Copyright 2010 Lennart Poettering | |
10 | ||
11 | systemd is free software; you can redistribute it and/or modify it | |
12 | under the terms of the GNU General Public License as published by | |
13 | the Free Software Foundation; either version 2 of the License, or | |
14 | (at your option) any later version. | |
15 | ||
16 | systemd is distributed in the hope that it will be useful, but | |
17 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
19 | General Public License for more details. | |
20 | ||
21 | You should have received a copy of the GNU General Public License | |
22 | along with systemd; If not, see <http://www.gnu.org/licenses/>. | |
23 | --> | |
24 | ||
25 | <refentry id="systemd.service"> | |
26 | <refentryinfo> | |
27 | <title>systemd.service</title> | |
28 | <productname>systemd</productname> | |
29 | ||
30 | <authorgroup> | |
31 | <author> | |
32 | <contrib>Developer</contrib> | |
33 | <firstname>Lennart</firstname> | |
34 | <surname>Poettering</surname> | |
35 | <email>lennart@poettering.net</email> | |
36 | </author> | |
37 | </authorgroup> | |
38 | </refentryinfo> | |
39 | ||
40 | <refmeta> | |
41 | <refentrytitle>systemd.service</refentrytitle> | |
42 | <manvolnum>5</manvolnum> | |
43 | </refmeta> | |
44 | ||
45 | <refnamediv> | |
46 | <refname>systemd.service</refname> | |
47 | <refpurpose>systemd service configuration files</refpurpose> | |
48 | </refnamediv> | |
49 | ||
50 | <refsynopsisdiv> | |
51 | <para><filename>systemd.service</filename></para> | |
52 | </refsynopsisdiv> | |
53 | ||
54 | <refsect1> | |
55 | <title>Description</title> | |
56 | ||
1f812fea | 57 | <para>A unit configuration file whose name ends in |
65232ea7 LP |
58 | <filename>.service</filename> encodes information |
59 | about a process controlled and supervised by | |
60 | systemd.</para> | |
d1ab0ca0 LP |
61 | |
62 | <para>This man page lists the configuration options | |
63 | specific to this unit type. See | |
64 | <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry> | |
65 | for the common options of all unit configuration | |
0d624a78 | 66 | files. The common configuration items are configured |
62adf224 LP |
67 | in the generic <literal>[Unit]</literal> and |
68 | <literal>[Install]</literal> sections. The service | |
69 | specific configuration options are configured in the | |
70 | <literal>[Service]</literal> section.</para> | |
0d624a78 | 71 | |
ba60f905 LP |
72 | <para>Additional options are listed in |
73 | <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
74 | which define the execution environment the commands | |
75 | are executed in.</para> | |
62adf224 LP |
76 | |
77 | <para>Unless <varname>DefaultDependencies=</varname> | |
78 | is set to <option>false</option>, service units will | |
79 | implicitly have dependencies of type | |
80 | <varname>Requires=</varname> and | |
81 | <varname>After=</varname> on | |
82 | <filename>basic.target</filename> as well as | |
83 | dependencies of type <varname>Conflicts=</varname> and | |
84 | <varname>Before=</varname> on | |
85 | <filename>shutdown.target</filename>. These ensure | |
86 | that normal service units pull in basic system | |
87 | initialization, and are terminated cleanly prior to | |
88 | system shutdown. Only services involved with early | |
89 | boot or late system shutdown should disable this | |
90 | option.</para> | |
59a3e1bc LP |
91 | |
92 | <para>If a service is requested under a certain name | |
93 | but no unit configuration file is found, systemd looks | |
94 | for a SysV init script by the same name (with the | |
95 | <filename>.service</filename> suffix removed) and | |
96 | dynamically creates a service unit from that | |
97 | script. This is useful for compatibility with | |
98 | SysV.</para> | |
d1ab0ca0 LP |
99 | </refsect1> |
100 | ||
101 | <refsect1> | |
102 | <title>Options</title> | |
103 | ||
62adf224 LP |
104 | <para>Service files must include a |
105 | <literal>[Service]</literal> section, which carries | |
106 | information about the service and the process it | |
107 | supervises. A number of options that may be used in | |
108 | this section are shared with other unit types. These | |
109 | options are documented in | |
0d624a78 | 110 | <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>. The |
62adf224 LP |
111 | options specific to the <literal>[Service]</literal> |
112 | section of service units are the following:</para> | |
0d624a78 | 113 | |
d1ab0ca0 LP |
114 | <variablelist> |
115 | <varlistentry> | |
116 | <term><varname>Type=</varname></term> | |
0d624a78 LP |
117 | |
118 | <listitem><para>Configures the process | |
119 | start-up type for this service | |
120 | unit. One of <option>simple</option>, | |
121 | <option>forking</option>, | |
122 | <option>finish</option>, | |
123 | <option>dbus</option>, | |
124 | <option>notify</option>.</para> | |
125 | ||
126 | <para>If set to | |
127 | <option>simple</option> (the default | |
128 | value) it is expected that the process | |
129 | configured with | |
130 | <varname>ExecStart=</varname> is the | |
131 | main process of the service. In this | |
132 | mode, communication channels must be | |
133 | installed before the daemon is started | |
134 | up (e.g. sockets set up by systemd, | |
135 | via socket activation), as systemd | |
136 | will immediately proceed starting | |
137 | follow-up units.</para> | |
138 | ||
139 | <para>If set to | |
140 | <option>forking</option> it is | |
141 | expected that the process configured | |
142 | with <varname>ExecStart=</varname> | |
143 | will start up and call | |
144 | <function>fork()</function>. The | |
145 | parent process is expected to finish | |
146 | when start-up is complete and all | |
147 | communication channels set up. The | |
148 | child continues to run as the main | |
149 | daemon process. This is the behaviour | |
150 | of traditional UNIX daemons. If this | |
151 | setting is used, it is recommended to | |
152 | also use the | |
153 | <varname>PIDFile=</varname> option, so | |
154 | that systemd can identify the main | |
155 | process of the daemon. systemd will | |
156 | proceed starting follow-up units as | |
157 | soon as the parent process | |
158 | exits.</para> | |
159 | ||
160 | <para>Behaviour of | |
161 | <option>finish</option> is similar | |
162 | to <option>simple</option>, however | |
163 | it is expected that the process has to | |
164 | exit before systemd starts follow-up | |
165 | units. <varname>ValidNoProcess=</varname> | |
166 | is particularly useful for this type | |
167 | of service.</para> | |
168 | ||
169 | <para>Behaviour of | |
170 | <option>dbus</option> is similar to | |
62adf224 LP |
171 | <option>simple</option>, however it is |
172 | expected that the daemon acquires a | |
0d624a78 LP |
173 | name on the D-Bus bus, as configured |
174 | by | |
175 | <varname>BusName=</varname>. systemd | |
176 | will proceed starting follow-up units | |
177 | after the D-Bus bus name has been | |
62adf224 LP |
178 | acquired. Service units with this |
179 | option configured implicitly have | |
180 | dependencies on the | |
181 | <filename>dbus.target</filename> | |
182 | unit.</para> | |
0d624a78 LP |
183 | |
184 | <para>Behaviour of | |
185 | <option>notify</option> is similar to | |
186 | <option>simple</option>, however it is | |
187 | expected that the daemon sends a | |
188 | notification message via | |
189 | <citerefentry><refentrytitle>sd_notify</refentrytitle><manvolnum>3</manvolnum></citerefentry> | |
190 | or an equivalent call when it finished | |
191 | starting up. systemd will proceed | |
192 | starting follow-up units after this | |
193 | notification message has been sent. If | |
194 | this option is used | |
62adf224 | 195 | <varname>NotifyAccess=</varname> (see |
0d624a78 LP |
196 | below) must be set to open access to |
197 | the notification socket provided by | |
62adf224 LP |
198 | systemd. If |
199 | <varname>NotifyAccess=</varname> is not | |
200 | set, it will be implicitly set to | |
201 | <option>main</option>.</para> | |
d1ab0ca0 LP |
202 | </listitem> |
203 | </varlistentry> | |
0d624a78 | 204 | |
d1ab0ca0 LP |
205 | <varlistentry> |
206 | <term><varname>ValidNoProcess=</varname></term> | |
0d624a78 LP |
207 | |
208 | <listitem><para>Takes a boolean value | |
209 | that specifies whether the service | |
210 | shall be considered active even when | |
211 | all its processes exited. Defaults to | |
212 | <option>no</option>.</para> | |
d1ab0ca0 LP |
213 | </listitem> |
214 | </varlistentry> | |
215 | ||
216 | <varlistentry> | |
217 | <term><varname>PIDFile=</varname></term> | |
0d624a78 LP |
218 | |
219 | <listitem><para>Takes an absolute file | |
220 | name pointing to the PID file of this | |
221 | daemon. Use of this option is | |
222 | recommended for services where | |
223 | <varname>Type=</varname> is set to | |
224 | <option>forking</option>.</para> | |
d1ab0ca0 LP |
225 | </listitem> |
226 | </varlistentry> | |
227 | ||
228 | <varlistentry> | |
229 | <term><varname>BusName=</varname></term> | |
0d624a78 LP |
230 | |
231 | <listitem><para>Takes a D-Bus bus | |
232 | name, where this service is reachable | |
233 | as. This option is mandatory for | |
234 | services where | |
235 | <varname>Type=</varname> is set to | |
236 | <option>dbus</option>, but its use | |
237 | is otherwise recommended as well if | |
238 | the process takes a name on the D-Bus | |
239 | bus.</para> | |
d1ab0ca0 LP |
240 | </listitem> |
241 | </varlistentry> | |
242 | ||
243 | <varlistentry> | |
244 | <term><varname>ExecStart=</varname></term> | |
0d624a78 LP |
245 | <listitem><para>Takes a command line |
246 | that is executed when this service | |
247 | shall be started up. The first token | |
248 | of the command line must be an | |
249 | absolute file name, then followed by | |
250 | arguments for the process. It is | |
251 | mandatory to set this option for all | |
252 | services. This option may not be | |
253 | specified more than once. Optionally, | |
254 | if the absolute file name is prefixed | |
62adf224 LP |
255 | with <literal>@</literal>, the second |
256 | token will be passed as | |
257 | <literal>argv[0]</literal> to the | |
258 | executed process, followed by the | |
259 | further arguments specified. Unless | |
260 | <varname>Type=forking</varname> is set, | |
0d624a78 LP |
261 | the process started via this command |
262 | line will be considered the main | |
263 | process of the | |
264 | daemon.</para></listitem> | |
265 | </varlistentry> | |
266 | ||
267 | <varlistentry> | |
268 | <term><varname>ExecStartPre=</varname></term> | |
269 | <term><varname>ExecStartPost=</varname></term> | |
270 | <listitem><para>Additional commands | |
271 | that are executed before (resp. after) | |
272 | the command in | |
273 | <varname>ExecStart=</varname>. If | |
274 | specified more than once, all commands | |
275 | are executed one after the other, | |
276 | serially. Use of these settings is | |
277 | optional.</para></listitem> | |
278 | </varlistentry> | |
279 | ||
280 | <varlistentry> | |
281 | <term><varname>ExecReload=</varname></term> | |
282 | <listitem><para>Commands to execute to | |
283 | trigger a configuration reload in the | |
284 | service. If used more than once, all | |
285 | commands are executed one after the | |
286 | other, serially. Use of this setting is optional. | |
287 | </para></listitem> | |
288 | </varlistentry> | |
289 | ||
290 | <varlistentry> | |
291 | <term><varname>ExecStop=</varname></term> | |
292 | <listitem><para>Commands to execute to | |
293 | stop the service started via | |
294 | <varname>ExecStart=</varname>. If used | |
295 | more than once, all commands are | |
296 | executed one after the other, | |
297 | serially. Use of this setting is | |
298 | optional. All processes remaining for | |
299 | a service after the commands | |
300 | configured in this option are run are | |
301 | terminated according to the | |
302 | <varname>KillMode=</varname> setting | |
303 | (see below). If this option is not | |
304 | specified the process is terminated | |
305 | right-away when service stop is | |
306 | requested.</para></listitem> | |
307 | </varlistentry> | |
308 | ||
309 | <varlistentry> | |
310 | <term><varname>ExecStopPost=</varname></term> | |
311 | <listitem><para>Additional commands | |
312 | that are executed after the service | |
313 | was stopped using the commands | |
314 | configured in | |
315 | <varname>ExecStop=</varname>. If | |
316 | specified more than once, all commands | |
317 | are executed one after the other, | |
318 | serially. Use of these settings is | |
319 | optional.</para></listitem> | |
320 | </varlistentry> | |
321 | ||
322 | <varlistentry> | |
323 | <term><varname>RestartSec=</varname></term> | |
324 | <listitem><para>Configures the time to | |
325 | sleep before restarting a service (as | |
326 | configured with | |
327 | <varname>Restart=</varname>). Takes a | |
328 | unit-less value in seconds, or a time | |
329 | span value such as "5min | |
330 | 20s". Defaults to | |
331 | 100ms.</para></listitem> | |
332 | </varlistentry> | |
333 | ||
334 | <varlistentry> | |
335 | <term><varname>TimeoutSec=</varname></term> | |
336 | <listitem><para>Configures the time to | |
337 | wait for start-up and stop. If a | |
338 | daemon service does not signal | |
339 | start-up completion within the | |
340 | configured time the service will be | |
341 | considered failed and be shut down | |
342 | again. If a service is asked to stop | |
343 | but does not terminate in the | |
344 | specified time it will be terminated | |
345 | forcibly via SIGTERM, and after | |
346 | another delay of this time with | |
347 | SIGKILL. (See | |
62adf224 | 348 | <varname>KillMode=</varname> |
0d624a78 LP |
349 | below.) Takes a unit-less value in seconds, or a |
350 | time span value such as "5min | |
351 | 20s". Pass 0 to disable the timeout | |
352 | logic. Defaults to | |
353 | 60s.</para></listitem> | |
354 | </varlistentry> | |
355 | ||
356 | <varlistentry> | |
357 | <term><varname>Restart=</varname></term> | |
358 | <listitem><para>Configures whether the | |
359 | main service process shall be restarted when | |
360 | it exists. Takes one of | |
361 | <option>once</option>, | |
362 | <option>restart-on-success</option> or | |
363 | <option>restart-always</option>. If | |
364 | set to <option>once</option> (the | |
365 | default) the service will not be | |
366 | restarted when it exits. If set to | |
367 | <option>restart-on-success</option> it | |
368 | will be restarted only when it exited | |
369 | cleanly, i.e. terminated with an exit | |
370 | code of 0. If set to | |
371 | <option>restart-always</option> the | |
372 | service will be restarted regardless | |
373 | whether it exited cleanly or not, or | |
374 | got terminated abnormally by a | |
375 | signal.</para></listitem> | |
376 | </varlistentry> | |
377 | ||
378 | <varlistentry> | |
379 | <term><varname>PermissionsStartOnly=</varname></term> | |
380 | <listitem><para>Takes a boolean | |
381 | argument. If true, the permission | |
382 | related execution options as | |
383 | configured with | |
384 | <varname>User=</varname> and similar | |
385 | options (see | |
386 | <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry> | |
387 | for more information) are only applied | |
388 | to the process started with | |
389 | <varname>ExecStart=</varname>, and not | |
390 | to the various other | |
391 | <varname>ExecStartPre=</varname>, | |
392 | <varname>ExecStartPost=</varname>, | |
393 | <varname>ExecReload=</varname>, | |
394 | <varname>ExecStop=</varname>, | |
395 | <varname>ExecStopPost=</varname> | |
396 | commands. If false, the setting is | |
397 | applied to all configured commands the | |
398 | same way. Defaults to | |
399 | false.</para></listitem> | |
400 | </varlistentry> | |
401 | ||
402 | <varlistentry> | |
403 | <term><varname>RootDirectoryStartOnly=</varname></term> | |
404 | <listitem><para>Takes a boolean | |
405 | argument. If true, the root directory | |
406 | as configured with the | |
407 | <varname>RootDirectory=</varname> | |
408 | option (see | |
409 | <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry> | |
410 | for more information) is only applied | |
411 | to the process started with | |
412 | <varname>ExecStart=</varname>, and not | |
413 | to the various other | |
414 | <varname>ExecStartPre=</varname>, | |
415 | <varname>ExecStartPost=</varname>, | |
416 | <varname>ExecReload=</varname>, | |
417 | <varname>ExecStop=</varname>, | |
418 | <varname>ExecStopPost=</varname> | |
419 | commands. If false, the setting is | |
420 | applied to all configured commands the | |
421 | same way. Defaults to | |
422 | false.</para></listitem> | |
423 | </varlistentry> | |
424 | ||
425 | <varlistentry> | |
426 | <term><varname>SysVStartPriority=</varname></term> | |
427 | <listitem><para>Set the SysV start | |
428 | priority to use to order this service | |
429 | in relation to SysV services lacking | |
430 | LSB headers. This option is only | |
431 | necessary to fix ordering in relation | |
432 | to legacy SysV services, that have no | |
433 | ordering information encoded in the | |
434 | script headers. As such it should only | |
435 | be used as temporary compatibility | |
436 | option, and not be used in new unit | |
437 | files. Almost always it is a better | |
438 | choice to add explicit ordering | |
439 | directives via | |
440 | <varname>After=</varname> or | |
441 | <varname>Before=</varname>, | |
442 | instead. For more details see | |
443 | <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>. If | |
444 | used, pass an integer value in the | |
445 | range 0-99.</para></listitem> | |
446 | </varlistentry> | |
447 | ||
448 | <varlistentry> | |
449 | <term><varname>KillMode=</varname></term> | |
450 | <listitem><para>Specifies how | |
451 | processes of this service shall be | |
452 | killed. One of | |
453 | <option>control-group</option>, | |
454 | <option>process-group</option>, | |
455 | <option>process</option>, | |
456 | <option>none</option>.</para> | |
457 | ||
458 | <para>If set to | |
459 | <option>control-group</option> all | |
460 | remaining processes in the control | |
461 | group of this service will be | |
462 | terminated on service stop, after the | |
463 | stop command (as configured with | |
464 | <varname>ExecStop=</varname>) is | |
465 | executed. If set to | |
466 | <option>process-group</option> only | |
467 | the members of the process group of | |
468 | the main service process are | |
469 | killed. If set to | |
470 | <option>process</option> only the main | |
471 | process itself is killed. If set to | |
472 | <option>none</option> no process is | |
473 | killed. In this case only the stop | |
474 | command will be executed on service | |
475 | stop, but no process be killed | |
476 | otherwise. Processes remaining alive | |
477 | after stop are left in their control | |
478 | group and the control group continues | |
479 | to exist after stop unless it is | |
480 | empty. Defaults to | |
481 | <option>control-croup</option>.</para> | |
482 | ||
483 | <para>Processes will first be | |
484 | terminated via SIGTERM. If then after | |
485 | a delay (configured via the | |
62adf224 | 486 | <varname>TimeoutSec=</varname> option) |
0d624a78 LP |
487 | processes still remain, the |
488 | termination request is repeated with | |
489 | the SIGKILL signal. See | |
490 | <citerefentry><refentrytitle>kill</refentrytitle><manvolnum>2</manvolnum></citerefentry> | |
491 | for more | |
492 | information.</para></listitem> | |
493 | </varlistentry> | |
494 | ||
495 | <varlistentry> | |
496 | <term><varname>NonBlocking=</varname></term> | |
497 | <listitem><para>Set O_NONBLOCK flag | |
498 | for all file descriptors passed via | |
499 | socket-based activation. If true, all | |
500 | file descriptors >= 3 (i.e. all except | |
501 | STDIN/STDOUT/STDERR) will have | |
502 | the O_NONBLOCK flag set and hence are in | |
503 | non-blocking mode. This option is only | |
504 | useful in conjunction with a socket | |
505 | unit, as described in | |
506 | <citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry>. Defaults | |
507 | to false.</para></listitem> | |
508 | </varlistentry> | |
509 | ||
510 | <varlistentry> | |
511 | <term><varname>NotifyAccess=</varname></term> | |
512 | <listitem><para>Controls access to the | |
513 | service status notification socket, as | |
514 | accessible via the | |
515 | <citerefentry><refentrytitle>sd_notify</refentrytitle><manvolnum>3</manvolnum></citerefentry> | |
516 | call. Takes one of | |
517 | <option>none</option> (the default), | |
518 | <option>main</option> or | |
519 | <option>all</option>. If | |
520 | <option>none</option> no daemon status | |
521 | updates are accepted by the service | |
522 | processes, all status update messages | |
523 | are ignored. If <option>main</option> | |
524 | only service updates sent from the | |
525 | main process of the service are | |
526 | accepted. If <option>all</option> all | |
527 | services updates from all members of | |
528 | the service's control group are | |
529 | accepted. This option must be set to | |
530 | open access to the notification socket | |
531 | when using | |
532 | <varname>Type=notify</varname> (see above).</para></listitem> | |
d1ab0ca0 LP |
533 | </varlistentry> |
534 | ||
535 | </variablelist> | |
536 | </refsect1> | |
537 | ||
538 | <refsect1> | |
539 | <title>See Also</title> | |
540 | <para> | |
f3e219a2 | 541 | <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>, |
0d624a78 LP |
542 | <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>8</manvolnum></citerefentry>, |
543 | <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
544 | <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry> | |
d1ab0ca0 LP |
545 | </para> |
546 | </refsect1> | |
547 | ||
548 | </refentry> |