]> git.ipfire.org Git - thirdparty/systemd.git/blame - man/systemd.unit.xml
man: refer to snapshot man page from unit man page
[thirdparty/systemd.git] / man / systemd.unit.xml
CommitLineData
d1ab0ca0
LP
1<?xml version='1.0'?> <!--*-nxml-*-->
2<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
4
5<!--
6 This file is part of systemd.
7
8 Copyright 2010 Lennart Poettering
9
10 systemd is free software; you can redistribute it and/or modify it
11 under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
14
15 systemd is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with systemd; If not, see <http://www.gnu.org/licenses/>.
22-->
23
24<refentry id="systemd.unit">
25
26 <refentryinfo>
27 <title>systemd.unit</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.unit</refentrytitle>
42 <manvolnum>5</manvolnum>
43 </refmeta>
44
45 <refnamediv>
46 <refname>systemd.unit</refname>
47 <refpurpose>systemd unit configuration files</refpurpose>
48 </refnamediv>
49
50 <refsynopsisdiv>
11e29955
LP
51 <para><filename>systemd.service</filename>,
52 <filename>systemd.socket</filename>,
53 <filename>systemd.device</filename>,
54 <filename>systemd.mount</filename>,
55 <filename>systemd.automount</filename>,
56 <filename>systemd.swap</filename>,
57 <filename>systemd.target</filename>,
58 <filename>systemd.path</filename>,
5f2ee303
LP
59 <filename>systemd.timer</filename>,
60 <filename>systemd.snapshot</filename></para>
d1ab0ca0
LP
61 </refsynopsisdiv>
62
63 <refsect1>
64 <title>Description</title>
65
66 <para>A unit configuration file encodes information
771610b0 67 about a service, a socket, a device, a mount point, an
436c44a5 68 automount point, a swap file or partition, a start-up
771610b0 69 target, a file system path or a timer controlled and
11e29955
LP
70 supervised by
71 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>. The
72 syntax is inspired by <ulink
73 url="http://standards.freedesktop.org/desktop-entry-spec/latest/">XDG
4176e530 74 Desktop Entry Specification</ulink> <filename>.desktop</filename> files, which are in turn
11e29955
LP
75 inspired by Microsoft Windows
76 <filename>.ini</filename> files.</para>
d1ab0ca0
LP
77
78 <para>This man pages lists the common configuration
771610b0 79 options of the all unit types. These options need to
11e29955 80 be configured in the [Unit] resp. [Install]
771610b0 81 section of the unit files.</para>
11e29955
LP
82
83 <para>In addition to the generic [Unit] and [Install]
84 sections described here each unit should have a
85 type-specific section, e.g. [Service] for a service
86 unit. See the respective man pages for more
87 information.</para>
88
89 <para>Unit files may contain additional options on top
90 of those listed here. If systemd encounters an unknown
91 option it will write a warning log message but
92 continue loading the unit. If an option is prefixed
93 with <option>X-</option> it is ignored completely by
94 systemd. Applications may use this to include
95 additional information in the unit files.</para>
96
97 <para>Boolean arguments used in unit files can be
6cbdbc5f 98 written in various formats. For positive settings the
11e29955
LP
99 strings <option>1</option>, <option>yes</option>,
100 <option>true</option> and <option>on</option> are
101 equivalent. For negative settings the strings
102 <option>0</option>, <option>no</option>,
103 <option>false</option> and <option>off</option> are
104 equivalent.</para>
105
0d624a78
LP
106 <para>Time span values encoded in unit files can be
107 written in various formats. A stand-alone number
108 specifies a time in seconds. If suffixed with a time
b439c6ee 109 unit, the unit is honored. A concatenation of
0d624a78
LP
110 multiple value with units is supported, in which case
111 the values are added up. Example: "50" refers to 50
112 seconds; "2min 200ms" refers to 2 minutes plus 200
113 milliseconds, i.e. 120200ms. The following time units
114 are understood: s, min, h, d, w, ms, us.</para>
115
11e29955
LP
116 <para>Empty lines and lines starting with # or ; are
117 ignored. This may be used for commenting.</para>
118
119 <para>If a line starts with <option>.include</option>
120 followed by a file name the specified file will be
121 read as if its contents where listed in place of the
122 <option>.include</option> directive.</para>
123
124 <para>Along with a unit file
125 <filename>foo.service</filename> a directory
126 <filename>foo.service.wants/</filename> may exist. All
127 units symlinked from such a directory are implicitly
128 added as dependencies of type
129 <varname>Wanted=</varname> to the unit. This is useful
130 to hook units into the start-up of other units,
131 without having to modify their unit configuration
132 files. For details about the semantics of
133 <varname>Wanted=</varname> see below. The preferred
134 way to create symlinks in the
135 <filename>.wants/</filename> directory of a service is
136 with the
137 <citerefentry><refentrytitle>systemd-install</refentrytitle><manvolnum>1</manvolnum></citerefentry>
138 tool which reads information from the [Install]
139 section of unit files. (See below.)</para>
140
141 <para>Note that while systemd offers a flexible
142 dependency system between units it is recommended to
143 use this functionality only sparsely and instead rely
144 on techniques such as bus-based or socket-based
145 activation which makes dependencies implicit, which
146 both results in a simpler and more flexible
147 system.</para>
1f812fea
LP
148
149 <para>Some unit names reflect paths existing in the
150 file system name space. Example: a device unit
151 <filename>dev-sda.device</filename> refers to a device
152 with the device node <filename>/dev/sda</filename> in
153 the file system namespace. If this applies a special
154 way to escape the path name is used, so that it is
b2c20dd9
LP
155 usable as part of a file name. Basically, given a
156 path, "/" is replaced by "-", and all unprintable
157 characters and the "-" are replaced by C-style "\x20"
158 escapes. The root directory "/" is encoded as single
159 dash, while otherwise the initial and ending "/" is
160 removed from all paths during transformation. This
161 escaping is reversible.</para>
1f812fea
LP
162
163 <para>Optionally, units may be instantiated from a
164 template file at runtime. This allows creation of
165 multiple units from a single configuration file. If
166 systemd looks for a unit configuration file it will
167 first search for the literal unit name in the
168 filesystem. If that yields no success and the unit
169 name contains an @ character, systemd will look for a
170 unit template that shares the same name but with the
171 instance string (i.e. the part between the @ character
172 and the suffix) removed. Example: if a service
173 <filename>getty@tty3.service</filename> is requested
174 and no file by that name is found, systemd will look
175 for <filename>getty@.service</filename> and
176 instantiate a service from that configuration file if
177 it is found. To refer to the instance string from
178 within the configuration file you may use the special
179 <literal>%i</literal> specifier in many of the
180 configuration options. Other specifiers that may be
181 used are <literal>%n</literal>, <literal>%N</literal>,
182 <literal>%p</literal>, <literal>%P</literal> and
183 <literal>%I</literal>, for the full unit name, the
184 unescaped unit name, the prefix name, the unescaped
185 prefix name and the unescaped instance name,
186 respectively. The prefix name here refers to the
187 string before the @, i.e. "getty" in the example
188 above, where "tty3" is the instance name.</para>
d1ab0ca0
LP
189 </refsect1>
190
191 <refsect1>
192 <title>Options</title>
193
771610b0
LP
194 <para>Unit file may include a [Unit] section, which
195 carries generic information about the unit that is not
196 dependent on the type of unit:</para>
197
d1ab0ca0
LP
198 <variablelist>
199 <varlistentry>
9f235308 200 <term><varname>Names=</varname></term>
771610b0
LP
201
202 <listitem><para>Additional names for
203 this unit. The names listed here must
204 have the same suffix (i.e. type) as
205 the unit file name. This option may be
206 specified more than once, in which
207 case all listed names are used. Note
208 that this option is different from the
209 <varname>Alias=</varname> option from
210 the [Install] section mentioned
11e29955 211 below. See below for details.</para>
d1ab0ca0
LP
212 </listitem>
213 </varlistentry>
11e29955
LP
214
215 <varlistentry>
216 <term><varname>Description=</varname></term>
217 <listitem><para>A free-form string
218 describing the unit. This is intended for use
219 in UIs wanting to show
220 descriptive information along with the
221 unit name.</para></listitem>
222 </varlistentry>
223
d1ab0ca0 224 <varlistentry>
9f235308 225 <term><varname>Requires=</varname></term>
771610b0 226
11e29955 227 <listitem><para>Configures requirement
771610b0
LP
228 dependencies on other units. If this
229 units get activated the units listed
230 here will be activated as well. If one
231 of the other units gets deactivated or
232 its activation fails, this unit will
233 be deactivated. This option may be
234 specified more than once, in which
235 case requirement dependencies for all
11e29955
LP
236 listed names are created. Note that
237 requirement dependencies do not
238 influence the order in which services
239 are started or stopped. This has to be
240 configured independently with the
241 <varname>After=</varname> or
242 <varname>Before=</varname> options. If
243 a unit
244 <filename>foo.service</filename>
245 requires a unit
246 <filename>bar.service</filename> as
247 configured with
248 <varname>Requires=</varname> and no
249 ordering is configured with
250 <varname>After=</varname> or
251 <varname>Before=</varname>, then both
252 units will be started simultaneously
253 and without any delay between them if
254 <filename>foo.service</filename> is
255 activated. Often it is a better choice
256 to use <varname>Wants=</varname>
257 instead of
258 <varname>Requires=</varname> in order
259 to achieve a system that is more
260 robust when dealing with failing
261 services.</para></listitem>
d1ab0ca0 262 </varlistentry>
11e29955
LP
263
264
265 <varlistentry>
266 <term><varname>RequiresOverridable=</varname></term>
267
268 <listitem><para>Similar to
269 <varname>Requires=</varname>.
270 Dependencies listed in
271 <varname>RequiresOverridable=</varname>
272 which cannot be fulfilled or fail to
273 start are ignored iff the startup was
274 explicitly requested by the user. If
275 the start-up was pulled in indirectly
276 by some dependency or automatic
277 start-up of units that is not
278 requested by the user this dependency
279 must be fulfilled and otherwise the
280 transaction fails. Hence, this option
281 may be used to configure dependencies
4176e530 282 that are normally honored unless the
11e29955
LP
283 user explicitly starts up the unit, in
284 which case whether they failed or not
285 is irrelevant.</para></listitem>
286
287 </varlistentry>
288 <varlistentry>
289 <term><varname>Requisite=</varname></term>
290 <term><varname>RequisiteOverridable=</varname></term>
291
292 <listitem><para>Similar to
293 <varname>Requires=</varname>
294 resp. <varname>RequiresOverridable=</varname>. However,
295 if a unit listed here is not started
296 already it will not be started and the
297 transaction fails
298 immediately.</para></listitem>
299 </varlistentry>
300
301 <varlistentry>
302 <term><varname>Wants=</varname></term>
303
304 <listitem><para>A weaker version of
305 <varname>Requires=</varname>. A unit
306 listed in this option will be started
307 if the configuring unit is. However,
308 it the listed unit fails to start up
309 or cannot be added to the transaction
310 this has no impact on the validity of
311 the transaction as a whole. This is
312 the recommended way to hook start-up
313 of one unit to the start-up of another
314 unit. Note that dependencies of this
315 type may also be configured outside of
316 the unit configuration file by
317 adding a symlink to a
318 <filename>.wants/</filename> directory
319 accompanying the unit file. For
320 details see above.</para></listitem>
321 </varlistentry>
322
323 <varlistentry>
324 <term><varname>Conflicts=</varname></term>
325
326 <listitem><para>Configures negative
327 requirement dependencies. If a unit
328 that has a
329 <varname>Conflicts=</varname> setting
330 on another unit starting the former
331 will stop the latter and vice
332 versa. Note that this setting is
333 independent of and orthogonal to the
334 <varname>After=</varname> and
335 <varname>Before=</varname> ordering
336 dependencies.</para></listitem>
337 </varlistentry>
338
339 <varlistentry>
340 <term><varname>Before=</varname></term>
341 <term><varname>After=</varname></term>
342
343 <listitem><para>Configures ordering
344 dependencies between units. If a unit
345 <filename>foo.service</filename>
346 contains a setting
347 <option>Before=bar.service</option>
348 and both units are being started
349 <filename>bar.service</filename>'s
350 start-up is delayed until
351 <filename>foo.service</filename> is
352 started up. Note that this setting is
353 independent of and orthogonal to the
354 requirement dependencies as configured
355 by <varname>Requires=</varname>. It is
356 a common pattern to include a unit
357 name in both the
358 <varname>After=</varname> and
359 <varname>Requires=</varname> option in
360 which case the unit listed will be
361 started before the unit that is
362 configured with these options. This
363 option may be specified more than
364 once, in which case ordering
365 dependencies for all listed names are
366 created. <varname>After=</varname> is
367 the inverse of
368 <varname>Before=</varname>, i.e. while
369 <varname>After=</varname> ensures that
370 the configured unit is started after
371 the listed unit finished starting up,
372 <varname>Before=</varname> ensures the
373 opposite, i.e. that the configured
374 unit is fully started up before the
375 listed unit is started. Note that when
376 two units with an ordering dependency
377 between them are shut down, the
378 inverse of of the start-up order is
379 applied. i.e. if a unit is configured
380 with <varname>After=</varname> on
381 another unit, the former is stopped
382 before the latter if both are shut
383 down. If one unit with an ordering
384 dependency on another unit is shut
385 down while the latter is started up,
386 the shut down is ordered before the
387 start-up regardless whether the
388 ordering dependency is actually of
389 type <varname>After=</varname> or
390 <varname>Before=</varname>. If two
391 units have no ordering dependencies
392 between them they are shut down
393 resp. started up simultaneously, and
394 no ordering takes
395 place. </para></listitem>
396 </varlistentry>
397
398 <varlistentry>
399 <term><varname>RecursiveStop=</varname></term>
400
401 <listitem><para>Takes a boolean
402 argument. If <option>true</option> and
403 the unit stops without this being
404 requested by the user all units
405 depending on it will be stopped as
406 well. (e.g. if a service exits or
407 crashes on its own behalf, units using
408 it will be stopped) Note that normally
409 if a unit stops without user request
410 units depending on it will not be
411 terminated. Only if the user requested
412 shutdown of a unit all units depending
413 on the unit will be shut down as well
414 and at the same time. Defaults to
415 <option>false</option>.</para></listitem>
416 </varlistentry>
417
418 <varlistentry>
419 <term><varname>StopWhenUnneeded=</varname></term>
420
421 <listitem><para>Takes a boolean
422 argument. If <option>true</option>
423 this unit will be stopped when it is
424 no longer used. Note that in order to
425 minimize the work to be executed
426 systemd will by default not stop units
427 unless they are conflicting with other
428 units, or the user explicitly
429 requested their shut down. If this
430 option is set a unit will be
431 automatically cleaned up if no other
432 active unit requires it. Defaults to
433 <option>false</option>.</para></listitem>
434 </varlistentry>
435
436 <varlistentry>
437 <term><varname>OnlyByDependency=</varname></term>
438
439 <listitem><para>Takes a boolean
440 argument. If <option>true</option>
441 this unit may only be activated
442 indirectly. In this case explicit
443 start-up requested by the user is
444 denied, however if it is started as
445 dependency of another unit start-up
446 will succeed. This is mostly a safety
447 feature to ensure that the user does
4176e530 448 not accidentally activate units that are
11e29955
LP
449 not intended to be activated
450 explicitly. This option defaults to
451 <option>false</option>.</para></listitem>
452 </varlistentry>
453
d1ab0ca0 454 </variablelist>
771610b0
LP
455
456 <para>Unit file may include a [Install] section, which
457 carries installation information for the unit. This
458 section is not interpreted by
459 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>
460 during runtime. It is used exclusively by the
461 <citerefentry><refentrytitle>systemd-install</refentrytitle><manvolnum>1</manvolnum></citerefentry>
11e29955 462 tool during installation of a unit:</para>
771610b0
LP
463
464 <variablelist>
465 <varlistentry>
466 <term><varname>Alias=</varname></term>
467
af62c704 468 <listitem><para>Additional names, this
771610b0
LP
469 unit shall be installed under. The
470 names listed here must have the same
471 suffix (i.e. type) as the unit file
472 name. This option may be specified
473 more than once, in which case all
474 listed names are used. At installation
af62c704 475 time,
771610b0
LP
476 <command>systemd-install</command>
477 will create symlinks from these names
478 to the unit file name. Note that this
479 is different from the
480 <varname>Names=</varname> option from
481 the [Unit] section mentioned above:
482 The names from
483 <varname>Names=</varname> apply
484 unconditionally if the unit is
485 loaded. The names from
486 <varname>Alias=</varname> apply only
11e29955
LP
487 if the unit has actually been
488 installed with the
489 <command>systemd-install</command>
771610b0
LP
490 tool. Also, if systemd searches for a
491 unit, it will discover symlinked alias
11e29955
LP
492 names as configured with
493 <varname>Alias=</varname>, but not
494 names configured with
495 <varname>Names=</varname> only. It is
496 a common pattern to list a name in
497 both options. In this case, a unit
498 will be active under all names if
499 installed, but also if not installed
500 but requested explicitly under its
501 main name.</para></listitem>
502 </varlistentry>
503
504 <varlistentry>
505 <term><varname>WantedBy=</varname></term>
506
507 <listitem><para>Installs a symlink in
508 the <filename>.wants/</filename>
509 subdirectory for a unit. This has the
510 effect that when the listed unit name
511 is activated the unit listing it is
512 activated
6cbdbc5f 513 too. <command>WantedBy=foo.service</command>
11e29955
LP
514 in a service
515 <filename>bar.service</filename> is
516 mostly equivalent to
517 <command>Alias=foo.service.wants/bar.service</command>
518 in the same file.</para></listitem>
519 </varlistentry>
520
521 <varlistentry>
522 <term><varname>Also=</varname></term>
523
524 <listitem><para>Additional units to
525 install when this unit is
526 installed. If the user requests
527 installation of a unit with this
528 option configured
529 <command>systemd-install</command>
530 will automatically install units
531 listed in this option as
532 well.</para></listitem>
771610b0
LP
533 </varlistentry>
534 </variablelist>
535
d1ab0ca0
LP
536 </refsect1>
537
538 <refsect1>
160cd5c9
LP
539 <title>See Also</title>
540 <para>
541 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
771610b0
LP
542 <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
543 <citerefentry><refentrytitle>systemd-install</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
544 <citerefentry><refentrytitle>systemd.special</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
545 <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
546 <citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
547 <citerefentry><refentrytitle>systemd.device</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
548 <citerefentry><refentrytitle>systemd.mount</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
549 <citerefentry><refentrytitle>systemd.automount</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
550 <citerefentry><refentrytitle>systemd.swap</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
551 <citerefentry><refentrytitle>systemd.target</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
552 <citerefentry><refentrytitle>systemd.path</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
5f2ee303
LP
553 <citerefentry><refentrytitle>systemd.timer</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
554 <citerefentry><refentrytitle>systemd.snapshot</refentrytitle><manvolnum>5</manvolnum></citerefentry>
160cd5c9 555 </para>
d1ab0ca0
LP
556 </refsect1>
557
558</refentry>