]>
Commit | Line | Data |
---|---|---|
d1ab0ca0 LP |
1 | <?xml version='1.0'?> <!--*-nxml-*--> |
2 | <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" | |
1a13e31d ZJS |
3 | "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [ |
4 | <!ENTITY % entities SYSTEM "custom-entities.ent" > | |
5 | %entities; | |
6 | ]> | |
d1ab0ca0 LP |
7 | |
8 | <!-- | |
9 | This file is part of systemd. | |
10 | ||
11 | Copyright 2010 Lennart Poettering | |
12 | ||
13 | systemd is free software; you can redistribute it and/or modify it | |
5430f7f2 LP |
14 | under the terms of the GNU Lesser General Public License as published by |
15 | the Free Software Foundation; either version 2.1 of the License, or | |
d1ab0ca0 LP |
16 | (at your option) any later version. |
17 | ||
18 | systemd is distributed in the hope that it will be useful, but | |
19 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
5430f7f2 | 21 | Lesser General Public License for more details. |
d1ab0ca0 | 22 | |
5430f7f2 | 23 | You should have received a copy of the GNU Lesser General Public License |
d1ab0ca0 LP |
24 | along with systemd; If not, see <http://www.gnu.org/licenses/>. |
25 | --> | |
26 | ||
27 | <refentry id="systemd.unit"> | |
28 | ||
29 | <refentryinfo> | |
30 | <title>systemd.unit</title> | |
31 | <productname>systemd</productname> | |
32 | ||
33 | <authorgroup> | |
34 | <author> | |
35 | <contrib>Developer</contrib> | |
36 | <firstname>Lennart</firstname> | |
37 | <surname>Poettering</surname> | |
38 | <email>lennart@poettering.net</email> | |
39 | </author> | |
40 | </authorgroup> | |
41 | </refentryinfo> | |
42 | ||
43 | <refmeta> | |
44 | <refentrytitle>systemd.unit</refentrytitle> | |
45 | <manvolnum>5</manvolnum> | |
46 | </refmeta> | |
47 | ||
48 | <refnamediv> | |
49 | <refname>systemd.unit</refname> | |
34511ca7 | 50 | <refpurpose>Unit configuration</refpurpose> |
d1ab0ca0 LP |
51 | </refnamediv> |
52 | ||
53 | <refsynopsisdiv> | |
13219b7f ZJS |
54 | <para><filename><replaceable>service</replaceable>.service</filename>, |
55 | <filename><replaceable>socket</replaceable>.socket</filename>, | |
56 | <filename><replaceable>device</replaceable>.device</filename>, | |
57 | <filename><replaceable>mount</replaceable>.mount</filename>, | |
58 | <filename><replaceable>automount</replaceable>.automount</filename>, | |
59 | <filename><replaceable>swap</replaceable>.swap</filename>, | |
60 | <filename><replaceable>target</replaceable>.target</filename>, | |
61 | <filename><replaceable>path</replaceable>.path</filename>, | |
62 | <filename><replaceable>timer</replaceable>.timer</filename>, | |
e73eebfd LP |
63 | <filename><replaceable>snapshot</replaceable>.snapshot</filename>, |
64 | <filename><replaceable>slice</replaceable>.slice</filename>, | |
65 | <filename><replaceable>scope</replaceable>.scope</filename></para> | |
13219b7f ZJS |
66 | |
67 | <para><literallayout><filename>/etc/systemd/system/*</filename> | |
68 | <filename>/run/systemd/system/*</filename> | |
69 | <filename>/usr/lib/systemd/system/*</filename> | |
70 | <filename>...</filename> | |
71 | </literallayout></para> | |
72 | ||
73 | <para><literallayout><filename>/etc/systemd/user/*</filename> | |
74 | <filename>/run/systemd/user/*</filename> | |
75 | <filename>/usr/lib/systemd/user/*</filename> | |
76 | <filename>...</filename> | |
77 | </literallayout></para> | |
d1ab0ca0 LP |
78 | </refsynopsisdiv> |
79 | ||
80 | <refsect1> | |
81 | <title>Description</title> | |
82 | ||
83 | <para>A unit configuration file encodes information | |
771610b0 | 84 | about a service, a socket, a device, a mount point, an |
436c44a5 | 85 | automount point, a swap file or partition, a start-up |
e73eebfd LP |
86 | target, a watched file system path, a timer controlled |
87 | and supervised by | |
88 | <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>, | |
89 | a temporary system state snapshot, a resource | |
90 | management slice or a group of externally created | |
91 | processes. The syntax is inspired by <ulink | |
11e29955 | 92 | url="http://standards.freedesktop.org/desktop-entry-spec/latest/">XDG |
e73eebfd LP |
93 | Desktop Entry Specification</ulink> |
94 | <filename>.desktop</filename> files, which are in turn | |
11e29955 LP |
95 | inspired by Microsoft Windows |
96 | <filename>.ini</filename> files.</para> | |
d1ab0ca0 | 97 | |
bb31a4ac | 98 | <para>This man page lists the common configuration |
58c16a1a | 99 | options of all the unit types. These options need to |
16dad32e AE |
100 | be configured in the [Unit] or [Install] |
101 | sections of the unit files.</para> | |
11e29955 LP |
102 | |
103 | <para>In addition to the generic [Unit] and [Install] | |
8afbb8e1 | 104 | sections described here, each unit may have a |
11e29955 LP |
105 | type-specific section, e.g. [Service] for a service |
106 | unit. See the respective man pages for more | |
13219b7f ZJS |
107 | information: |
108 | <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
109 | <citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
110 | <citerefentry><refentrytitle>systemd.device</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
111 | <citerefentry><refentrytitle>systemd.mount</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
112 | <citerefentry><refentrytitle>systemd.automount</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
113 | <citerefentry><refentrytitle>systemd.swap</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
114 | <citerefentry><refentrytitle>systemd.target</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
115 | <citerefentry><refentrytitle>systemd.path</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
116 | <citerefentry><refentrytitle>systemd.timer</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
117 | <citerefentry><refentrytitle>systemd.snapshot</refentrytitle><manvolnum>5</manvolnum></citerefentry>. | |
e73eebfd LP |
118 | <citerefentry><refentrytitle>systemd.slice</refentrytitle><manvolnum>5</manvolnum></citerefentry>. |
119 | <citerefentry><refentrytitle>systemd.scope</refentrytitle><manvolnum>5</manvolnum></citerefentry>. | |
13219b7f ZJS |
120 | </para> |
121 | ||
122 | <para>Unit files are loaded from a set of paths | |
123 | determined during compilation, described in the next section. | |
124 | </para> | |
11e29955 LP |
125 | |
126 | <para>Unit files may contain additional options on top | |
127 | of those listed here. If systemd encounters an unknown | |
128 | option it will write a warning log message but | |
129 | continue loading the unit. If an option is prefixed | |
130 | with <option>X-</option> it is ignored completely by | |
131 | systemd. Applications may use this to include | |
132 | additional information in the unit files.</para> | |
133 | ||
134 | <para>Boolean arguments used in unit files can be | |
6cbdbc5f | 135 | written in various formats. For positive settings the |
11e29955 LP |
136 | strings <option>1</option>, <option>yes</option>, |
137 | <option>true</option> and <option>on</option> are | |
138 | equivalent. For negative settings the strings | |
139 | <option>0</option>, <option>no</option>, | |
140 | <option>false</option> and <option>off</option> are | |
141 | equivalent.</para> | |
142 | ||
0d624a78 LP |
143 | <para>Time span values encoded in unit files can be |
144 | written in various formats. A stand-alone number | |
145 | specifies a time in seconds. If suffixed with a time | |
8afbb8e1 LP |
146 | unit, the unit is honored. A concatenation of multiple |
147 | values with units is supported, in which case the | |
148 | values are added up. Example: "50" refers to 50 | |
0d624a78 LP |
149 | seconds; "2min 200ms" refers to 2 minutes plus 200 |
150 | milliseconds, i.e. 120200ms. The following time units | |
8afbb8e1 LP |
151 | are understood: s, min, h, d, w, ms, us. For details |
152 | see | |
153 | <citerefentry><refentrytitle>systemd.time</refentrytitle><manvolnum>7</manvolnum></citerefentry>.</para> | |
0d624a78 | 154 | |
11e29955 | 155 | <para>Empty lines and lines starting with # or ; are |
b3eaa628 LP |
156 | ignored. This may be used for commenting. Lines ending |
157 | in a backslash are concatenated with the following | |
158 | line while reading and the backslash is replaced by a | |
159 | space character. This may be used to wrap long lines.</para> | |
11e29955 | 160 | |
11e29955 | 161 | <para>Along with a unit file |
8afbb8e1 | 162 | <filename>foo.service</filename> the directory |
11e29955 | 163 | <filename>foo.service.wants/</filename> may exist. All |
8afbb8e1 LP |
164 | unit files symlinked from such a directory are |
165 | implicitly added as dependencies of type | |
11e29955 LP |
166 | <varname>Wanted=</varname> to the unit. This is useful |
167 | to hook units into the start-up of other units, | |
8afbb8e1 LP |
168 | without having to modify their unit files. For details |
169 | about the semantics of <varname>Wanted=</varname> see | |
170 | below. The preferred way to create symlinks in the | |
171 | <filename>.wants/</filename> directory of a unit file | |
172 | is with the <command>enable</command> command of the | |
ee5762e3 | 173 | <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry> |
11e29955 | 174 | tool which reads information from the [Install] |
8afbb8e1 | 175 | section of unit files (see below). A similar |
0732ec00 LP |
176 | functionality exists for <varname>Requires=</varname> |
177 | type dependencies as well, the directory suffix is | |
178 | <filename>.requires/</filename> in this case.</para> | |
11e29955 | 179 | |
8afbb8e1 LP |
180 | <para>Along with a unit file |
181 | <filename>foo.service</filename> a directory | |
182 | <filename>foo.service.d/</filename> may exist. All | |
479fe882 | 183 | files with the suffix <literal>.conf</literal> from |
8afbb8e1 LP |
184 | this directory will be parsed after the file itself is |
185 | parsed. This is useful to alter or add configuration | |
186 | settings to a unit, without having to modify their | |
187 | unit files. Make sure that the file that is included | |
188 | has the appropriate section headers before any | |
189 | directive.</para> | |
190 | ||
191 | <para>If a line starts with <option>.include</option> | |
e9dd9f95 | 192 | followed by a filename, the specified file will be |
8afbb8e1 LP |
193 | parsed at this point. Make sure that the file that is |
194 | included has the appropriate section headers before | |
195 | any directives.</para> | |
196 | ||
11e29955 LP |
197 | <para>Note that while systemd offers a flexible |
198 | dependency system between units it is recommended to | |
e65c85ab | 199 | use this functionality only sparingly and instead rely |
11e29955 | 200 | on techniques such as bus-based or socket-based |
e65c85ab ZJS |
201 | activation which make dependencies implicit, resulting |
202 | in a both simpler and more flexible system.</para> | |
1f812fea LP |
203 | |
204 | <para>Some unit names reflect paths existing in the | |
12f25b6e | 205 | file system namespace. Example: a device unit |
1f812fea | 206 | <filename>dev-sda.device</filename> refers to a device |
845c5324 | 207 | with the device node <filename noindex='true'>/dev/sda</filename> in |
1f812fea | 208 | the file system namespace. If this applies a special |
085b94ee | 209 | way to escape the path name is used, so that the |
e9dd9f95 | 210 | result is usable as part of a filename. Basically, |
085b94ee LP |
211 | given a path, "/" is replaced by "-", and all |
212 | unprintable characters and the "-" are replaced by | |
213 | C-style "\x20" escapes. The root directory "/" is | |
214 | encoded as single dash, while otherwise the initial | |
215 | and ending "/" is removed from all paths during | |
216 | transformation. This escaping is reversible.</para> | |
1f812fea LP |
217 | |
218 | <para>Optionally, units may be instantiated from a | |
219 | template file at runtime. This allows creation of | |
220 | multiple units from a single configuration file. If | |
221 | systemd looks for a unit configuration file it will | |
222 | first search for the literal unit name in the | |
223 | filesystem. If that yields no success and the unit | |
05cc7267 | 224 | name contains an <literal>@</literal> character, systemd will look for a |
1f812fea | 225 | unit template that shares the same name but with the |
05cc7267 | 226 | instance string (i.e. the part between the <literal>@</literal> character |
1f812fea LP |
227 | and the suffix) removed. Example: if a service |
228 | <filename>getty@tty3.service</filename> is requested | |
229 | and no file by that name is found, systemd will look | |
230 | for <filename>getty@.service</filename> and | |
231 | instantiate a service from that configuration file if | |
0e89268b MB |
232 | it is found.</para> |
233 | ||
234 | <para>To refer to the instance string from | |
1f812fea LP |
235 | within the configuration file you may use the special |
236 | <literal>%i</literal> specifier in many of the | |
8afbb8e1 | 237 | configuration options. See below for details.</para> |
b9aea954 | 238 | |
6daf4f90 LP |
239 | <para>If a unit file is empty (i.e. has the file size |
240 | 0) or is symlinked to <filename>/dev/null</filename> | |
241 | its configuration will not be loaded and it appears | |
242 | with a load state of <literal>masked</literal>, and | |
243 | cannot be activated. Use this as an effective way to | |
244 | fully disable a unit, making it impossible to start it | |
245 | even manually.</para> | |
246 | ||
b9aea954 LP |
247 | <para>The unit file format is covered by the |
248 | <ulink | |
249 | url="http://www.freedesktop.org/wiki/Software/systemd/InterfaceStabilityPromise">Interface | |
250 | Stability Promise</ulink>.</para> | |
8afbb8e1 | 251 | |
d1ab0ca0 LP |
252 | </refsect1> |
253 | ||
13219b7f | 254 | <refsect1> |
00d1818b | 255 | <title>Unit Load Path</title> |
13219b7f ZJS |
256 | |
257 | <para>Unit files are loaded from a set of paths | |
258 | determined during compilation, described in the two | |
259 | tables below. Unit files found in directories higher | |
260 | in the hierarchy override files with the same name | |
261 | lower in the hierarchy, thus allowing overrides. | |
262 | </para> | |
263 | ||
00d1818b | 264 | <para>When systemd is running in user mode |
13219b7f ZJS |
265 | (<option>--user</option>) and the variable |
266 | <varname>$SYSTEMD_UNIT_PATH</varname> is set, this | |
267 | contents of this variable overrides the unit load | |
268 | path. | |
269 | </para> | |
270 | ||
271 | <table> | |
272 | <title> | |
273 | Load path when running in system mode (<option>--system</option>). | |
274 | </title> | |
275 | ||
276 | <tgroup cols='2'> | |
277 | <colspec colname='path' /> | |
278 | <colspec colname='expl' /> | |
279 | <thead> | |
280 | <row> | |
281 | <entry>Path</entry> | |
282 | <entry>Description</entry> | |
283 | </row> | |
284 | </thead> | |
285 | <tbody> | |
286 | <row> | |
287 | <entry><filename>/run/systemd/generator.early</filename></entry> | |
00d1818b | 288 | <entry>Generated units (early)</entry> |
13219b7f ZJS |
289 | </row> |
290 | <row> | |
291 | <entry><filename>/etc/systemd/system</filename></entry> | |
00d1818b | 292 | <entry>Local configuration</entry> |
13219b7f ZJS |
293 | </row> |
294 | <row> | |
6f88df57 | 295 | <entry><filename>/run/systemd/system</filename></entry> |
13219b7f ZJS |
296 | <entry>Volatile units</entry> |
297 | </row> | |
298 | <row> | |
299 | <entry><filename>/run/systemd/generator</filename></entry> | |
00d1818b | 300 | <entry>Generated units (middle)</entry> |
13219b7f ZJS |
301 | </row> |
302 | <row> | |
303 | <entry><filename>/usr/local/lib/systemd/system</filename></entry> | |
304 | <entry>Units for local packages</entry> | |
305 | </row> | |
13219b7f ZJS |
306 | <row> |
307 | <entry><filename>/usr/lib/systemd/system</filename></entry> | |
00d1818b | 308 | <entry>Units for installed packages</entry> |
13219b7f ZJS |
309 | </row> |
310 | <row> | |
311 | <entry><filename>/run/systemd/generator.late</filename></entry> | |
00d1818b | 312 | <entry>Generated units (late)</entry> |
13219b7f ZJS |
313 | </row> |
314 | </tbody> | |
315 | </tgroup> | |
316 | </table> | |
317 | ||
318 | <table> | |
319 | <title> | |
320 | Load path when running in session mode (<option>--user</option>). | |
321 | </title> | |
322 | ||
323 | <tgroup cols='2'> | |
324 | <colspec colname='path' /> | |
325 | <colspec colname='expl' /> | |
326 | <thead> | |
327 | <row> | |
328 | <entry>Path</entry> | |
329 | <entry>Description</entry> | |
330 | </row> | |
331 | </thead> | |
332 | <tbody> | |
333 | <row> | |
334 | <entry><filename>/tmp/systemd-generator.early.<replaceable>XXXXXX</replaceable></filename></entry> | |
00d1818b | 335 | <entry>Generated units (early)</entry> |
13219b7f ZJS |
336 | </row> |
337 | <row> | |
338 | <entry><filename>/etc/systemd/user</filename></entry> | |
00d1818b | 339 | <entry>Local configuration</entry> |
13219b7f ZJS |
340 | </row> |
341 | <row> | |
342 | <entry><filename>/run/systemd/user</filename></entry> | |
343 | <entry>Volatile units</entry> | |
344 | </row> | |
345 | <row> | |
346 | <entry><filename>/tmp/systemd-generator.<replaceable>XXXXXX</replaceable></filename></entry> | |
00d1818b | 347 | <entry>Generated units (middle)</entry> |
13219b7f ZJS |
348 | </row> |
349 | <row> | |
350 | <entry><filename>/usr/local/lib/systemd/user</filename></entry> | |
00d1818b | 351 | <entry>Units for local packages</entry> |
13219b7f ZJS |
352 | </row> |
353 | <row> | |
354 | <entry><filename>/usr/lib/systemd/user</filename></entry> | |
00d1818b | 355 | <entry>Units for installed packages</entry> |
13219b7f ZJS |
356 | </row> |
357 | <row> | |
358 | <entry><filename>/tmp/systemd-generator.late.<replaceable>XXXXXX</replaceable></filename></entry> | |
00d1818b | 359 | <entry>Generated units (late)</entry> |
13219b7f ZJS |
360 | </row> |
361 | </tbody> | |
362 | </tgroup> | |
363 | </table> | |
364 | ||
13219b7f ZJS |
365 | <para>Additional units might be loaded into systemd |
366 | ("linked") from directories not on the unit load | |
367 | path. See the <command>link</command> command for | |
368 | <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>. | |
369 | </para> | |
370 | </refsect1> | |
371 | ||
d1ab0ca0 LP |
372 | <refsect1> |
373 | <title>Options</title> | |
374 | ||
771610b0 LP |
375 | <para>Unit file may include a [Unit] section, which |
376 | carries generic information about the unit that is not | |
377 | dependent on the type of unit:</para> | |
378 | ||
ccc9a4f9 | 379 | <variablelist class='unit-directives'> |
11e29955 LP |
380 | |
381 | <varlistentry> | |
382 | <term><varname>Description=</varname></term> | |
383 | <listitem><para>A free-form string | |
62adf224 LP |
384 | describing the unit. This is intended |
385 | for use in UIs to show descriptive | |
386 | information along with the unit | |
387 | name.</para></listitem> | |
11e29955 LP |
388 | </varlistentry> |
389 | ||
49dbfa7b LP |
390 | <varlistentry> |
391 | <term><varname>Documentation=</varname></term> | |
e9dd9f95 | 392 | <listitem><para>A space-separated list |
49dbfa7b LP |
393 | of URIs referencing documentation for |
394 | this unit or its | |
395 | configuration. Accepted are only URIs | |
396 | of the types | |
397 | <literal>http://</literal>, | |
398 | <literal>https://</literal>, | |
399 | <literal>file:</literal>, | |
400 | <literal>info:</literal>, | |
401 | <literal>man:</literal>. For more | |
402 | information about the syntax of these | |
e9dd9f95 | 403 | URIs, see |
f8a2ebbc LP |
404 | <citerefentry><refentrytitle>uri</refentrytitle><manvolnum>7</manvolnum></citerefentry>. The |
405 | URIs should be listed in order of | |
406 | relevance, starting with the most | |
407 | relevant. It is a good idea to first | |
408 | reference documentation that explains | |
409 | what the unit's purpose is, followed | |
410 | by how it is configured, followed by | |
74051b9b LP |
411 | any other related documentation. This |
412 | option may be specified more than once | |
413 | in which case the specified list of | |
414 | URIs is merged. If the empty string is | |
e9dd9f95 | 415 | assigned to this option, the list is |
74051b9b LP |
416 | reset and all prior assignments will |
417 | have no effect.</para></listitem> | |
49dbfa7b LP |
418 | </varlistentry> |
419 | ||
d1ab0ca0 | 420 | <varlistentry> |
9f235308 | 421 | <term><varname>Requires=</varname></term> |
771610b0 | 422 | |
11e29955 | 423 | <listitem><para>Configures requirement |
771610b0 | 424 | dependencies on other units. If this |
58c16a1a | 425 | unit gets activated, the units listed |
771610b0 LP |
426 | here will be activated as well. If one |
427 | of the other units gets deactivated or | |
428 | its activation fails, this unit will | |
429 | be deactivated. This option may be | |
430 | specified more than once, in which | |
431 | case requirement dependencies for all | |
11e29955 LP |
432 | listed names are created. Note that |
433 | requirement dependencies do not | |
434 | influence the order in which services | |
435 | are started or stopped. This has to be | |
436 | configured independently with the | |
437 | <varname>After=</varname> or | |
438 | <varname>Before=</varname> options. If | |
439 | a unit | |
440 | <filename>foo.service</filename> | |
441 | requires a unit | |
442 | <filename>bar.service</filename> as | |
443 | configured with | |
444 | <varname>Requires=</varname> and no | |
445 | ordering is configured with | |
446 | <varname>After=</varname> or | |
447 | <varname>Before=</varname>, then both | |
448 | units will be started simultaneously | |
449 | and without any delay between them if | |
450 | <filename>foo.service</filename> is | |
451 | activated. Often it is a better choice | |
452 | to use <varname>Wants=</varname> | |
453 | instead of | |
454 | <varname>Requires=</varname> in order | |
455 | to achieve a system that is more | |
456 | robust when dealing with failing | |
5c315b4f ZJS |
457 | services.</para> |
458 | ||
459 | <para>Note that dependencies of this | |
460 | type may also be configured outside of | |
461 | the unit configuration file by | |
462 | adding a symlink to a | |
463 | <filename>.requires/</filename> directory | |
464 | accompanying the unit file. For | |
465 | details see above.</para></listitem> | |
d1ab0ca0 | 466 | </varlistentry> |
11e29955 | 467 | |
11e29955 LP |
468 | <varlistentry> |
469 | <term><varname>RequiresOverridable=</varname></term> | |
470 | ||
471 | <listitem><para>Similar to | |
472 | <varname>Requires=</varname>. | |
473 | Dependencies listed in | |
474 | <varname>RequiresOverridable=</varname> | |
475 | which cannot be fulfilled or fail to | |
58c16a1a | 476 | start are ignored if the startup was |
11e29955 LP |
477 | explicitly requested by the user. If |
478 | the start-up was pulled in indirectly | |
479 | by some dependency or automatic | |
480 | start-up of units that is not | |
481 | requested by the user this dependency | |
482 | must be fulfilled and otherwise the | |
483 | transaction fails. Hence, this option | |
484 | may be used to configure dependencies | |
4176e530 | 485 | that are normally honored unless the |
11e29955 LP |
486 | user explicitly starts up the unit, in |
487 | which case whether they failed or not | |
488 | is irrelevant.</para></listitem> | |
489 | ||
490 | </varlistentry> | |
491 | <varlistentry> | |
492 | <term><varname>Requisite=</varname></term> | |
493 | <term><varname>RequisiteOverridable=</varname></term> | |
494 | ||
495 | <listitem><para>Similar to | |
496 | <varname>Requires=</varname> | |
16dad32e | 497 | and <varname>RequiresOverridable=</varname>, respectively. However, |
11e29955 LP |
498 | if a unit listed here is not started |
499 | already it will not be started and the | |
500 | transaction fails | |
501 | immediately.</para></listitem> | |
502 | </varlistentry> | |
503 | ||
504 | <varlistentry> | |
505 | <term><varname>Wants=</varname></term> | |
506 | ||
507 | <listitem><para>A weaker version of | |
508 | <varname>Requires=</varname>. A unit | |
509 | listed in this option will be started | |
510 | if the configuring unit is. However, | |
58c16a1a | 511 | if the listed unit fails to start up |
11e29955 LP |
512 | or cannot be added to the transaction |
513 | this has no impact on the validity of | |
514 | the transaction as a whole. This is | |
515 | the recommended way to hook start-up | |
516 | of one unit to the start-up of another | |
5c315b4f ZJS |
517 | unit.</para> |
518 | ||
519 | <para>Note that dependencies of this | |
11e29955 LP |
520 | type may also be configured outside of |
521 | the unit configuration file by | |
522 | adding a symlink to a | |
523 | <filename>.wants/</filename> directory | |
524 | accompanying the unit file. For | |
525 | details see above.</para></listitem> | |
526 | </varlistentry> | |
527 | ||
b81884e7 | 528 | <varlistentry> |
7f2cddae | 529 | <term><varname>BindsTo=</varname></term> |
b81884e7 LP |
530 | |
531 | <listitem><para>Configures requirement | |
532 | dependencies, very similar in style to | |
533 | <varname>Requires=</varname>, however | |
c5315881 | 534 | in addition to this behavior it also |
b81884e7 LP |
535 | declares that this unit is stopped |
536 | when any of the units listed suddenly | |
537 | disappears. Units can suddenly, | |
538 | unexpectedly disappear if a service | |
539 | terminates on its own choice, a device | |
540 | is unplugged or a mount point | |
21931dbe | 541 | unmounted without involvement of |
b81884e7 LP |
542 | systemd.</para></listitem> |
543 | </varlistentry> | |
544 | ||
85e9a101 MS |
545 | <varlistentry> |
546 | <term><varname>PartOf=</varname></term> | |
547 | ||
f3d52e8c MS |
548 | <listitem><para>Configures dependencies |
549 | similar to <varname>Requires=</varname>, | |
550 | but limited to stopping and restarting | |
551 | of units. When systemd stops or restarts | |
552 | the units listed here, the action is | |
553 | propagated to this unit. | |
554 | Note that this is a one way dependency - | |
555 | changes to this unit do not affect the | |
556 | listed units. | |
557 | </para></listitem> | |
85e9a101 MS |
558 | </varlistentry> |
559 | ||
11e29955 LP |
560 | <varlistentry> |
561 | <term><varname>Conflicts=</varname></term> | |
562 | ||
563 | <listitem><para>Configures negative | |
564 | requirement dependencies. If a unit | |
58c16a1a | 565 | has a |
11e29955 | 566 | <varname>Conflicts=</varname> setting |
58c16a1a | 567 | on another unit, starting the former |
11e29955 LP |
568 | will stop the latter and vice |
569 | versa. Note that this setting is | |
570 | independent of and orthogonal to the | |
571 | <varname>After=</varname> and | |
572 | <varname>Before=</varname> ordering | |
69dd2852 LP |
573 | dependencies.</para> |
574 | ||
575 | <para>If a unit A that conflicts with | |
576 | a unit B is scheduled to be started at | |
577 | the same time as B, the transaction | |
578 | will either fail (in case both are | |
579 | required part of the transaction) or | |
580 | be modified to be fixed (in case one | |
581 | or both jobs are not a required part | |
582 | of the transaction). In the latter | |
583 | case the job that is not the required | |
584 | will be removed, or in case both are | |
585 | not required the unit that conflicts | |
586 | will be started and the unit that is | |
587 | conflicted is | |
588 | stopped.</para></listitem> | |
11e29955 LP |
589 | </varlistentry> |
590 | ||
591 | <varlistentry> | |
592 | <term><varname>Before=</varname></term> | |
593 | <term><varname>After=</varname></term> | |
594 | ||
595 | <listitem><para>Configures ordering | |
596 | dependencies between units. If a unit | |
597 | <filename>foo.service</filename> | |
598 | contains a setting | |
599 | <option>Before=bar.service</option> | |
58c16a1a | 600 | and both units are being started, |
11e29955 LP |
601 | <filename>bar.service</filename>'s |
602 | start-up is delayed until | |
603 | <filename>foo.service</filename> is | |
604 | started up. Note that this setting is | |
605 | independent of and orthogonal to the | |
606 | requirement dependencies as configured | |
607 | by <varname>Requires=</varname>. It is | |
608 | a common pattern to include a unit | |
609 | name in both the | |
610 | <varname>After=</varname> and | |
611 | <varname>Requires=</varname> option in | |
612 | which case the unit listed will be | |
613 | started before the unit that is | |
614 | configured with these options. This | |
615 | option may be specified more than | |
616 | once, in which case ordering | |
617 | dependencies for all listed names are | |
618 | created. <varname>After=</varname> is | |
619 | the inverse of | |
620 | <varname>Before=</varname>, i.e. while | |
621 | <varname>After=</varname> ensures that | |
622 | the configured unit is started after | |
623 | the listed unit finished starting up, | |
624 | <varname>Before=</varname> ensures the | |
625 | opposite, i.e. that the configured | |
626 | unit is fully started up before the | |
627 | listed unit is started. Note that when | |
628 | two units with an ordering dependency | |
629 | between them are shut down, the | |
58c16a1a | 630 | inverse of the start-up order is |
11e29955 LP |
631 | applied. i.e. if a unit is configured |
632 | with <varname>After=</varname> on | |
633 | another unit, the former is stopped | |
634 | before the latter if both are shut | |
635 | down. If one unit with an ordering | |
636 | dependency on another unit is shut | |
637 | down while the latter is started up, | |
638 | the shut down is ordered before the | |
639 | start-up regardless whether the | |
640 | ordering dependency is actually of | |
641 | type <varname>After=</varname> or | |
642 | <varname>Before=</varname>. If two | |
643 | units have no ordering dependencies | |
644 | between them they are shut down | |
16dad32e | 645 | or started up simultaneously, and |
11e29955 LP |
646 | no ordering takes |
647 | place. </para></listitem> | |
648 | </varlistentry> | |
649 | ||
b9975629 LP |
650 | <varlistentry> |
651 | <term><varname>OnFailure=</varname></term> | |
652 | ||
653 | <listitem><para>Lists one or more | |
654 | units that are activated when this | |
74ac3cbd | 655 | unit enters the |
909f413d | 656 | <literal>failed</literal> |
74ac3cbd | 657 | state.</para></listitem> |
b9975629 LP |
658 | </varlistentry> |
659 | ||
4dcc1cb4 | 660 | <varlistentry> |
7f2cddae LP |
661 | <term><varname>PropagatesReloadTo=</varname></term> |
662 | <term><varname>ReloadPropagatedFrom=</varname></term> | |
4dcc1cb4 LP |
663 | |
664 | <listitem><para>Lists one or more | |
665 | units where reload requests on the | |
666 | unit will be propagated to/on the | |
667 | other unit will be propagated | |
668 | from. Issuing a reload request on a | |
669 | unit will automatically also enqueue a | |
670 | reload request on all units that the | |
671 | reload request shall be propagated to | |
672 | via these two | |
673 | settings.</para></listitem> | |
674 | </varlistentry> | |
675 | ||
7c8fa05c LP |
676 | <varlistentry> |
677 | <term><varname>RequiresMountsFor=</varname></term> | |
678 | ||
e9dd9f95 JSJ |
679 | <listitem><para>Takes a space-separated |
680 | list of absolute paths. Automatically | |
7c8fa05c LP |
681 | adds dependencies of type |
682 | <varname>Requires=</varname> and | |
683 | <varname>After=</varname> for all | |
684 | mount units required to access the | |
685 | specified path.</para></listitem> | |
686 | </varlistentry> | |
687 | ||
222ae6a8 LP |
688 | <varlistentry> |
689 | <term><varname>OnFailureIsolate=</varname></term> | |
690 | ||
691 | <listitem><para>Takes a boolean | |
692 | argument. If <option>true</option> the | |
693 | unit listed in | |
694 | <varname>OnFailure=</varname> will be | |
695 | enqueued in isolation mode, i.e. all | |
696 | units that are not its dependency will | |
697 | be stopped. If this is set only a | |
698 | single unit may be listed in | |
699 | <varname>OnFailure=</varname>. Defaults | |
700 | to | |
701 | <option>false</option>.</para></listitem> | |
702 | </varlistentry> | |
703 | ||
c8f4d764 LP |
704 | <varlistentry> |
705 | <term><varname>IgnoreOnIsolate=</varname></term> | |
706 | ||
707 | <listitem><para>Takes a boolean | |
708 | argument. If <option>true</option> | |
709 | this unit will not be stopped when | |
710 | isolating another unit. Defaults to | |
711 | <option>false</option>.</para></listitem> | |
712 | </varlistentry> | |
713 | ||
7a6000a6 LP |
714 | <varlistentry> |
715 | <term><varname>IgnoreOnSnapshot=</varname></term> | |
716 | ||
717 | <listitem><para>Takes a boolean | |
718 | argument. If <option>true</option> | |
719 | this unit will not be included in | |
720 | snapshots. Defaults to | |
4e7f8bc8 ZJS |
721 | <option>true</option> for device and |
722 | snapshot units, <option>false</option> | |
7a6000a6 LP |
723 | for the others.</para></listitem> |
724 | </varlistentry> | |
725 | ||
11e29955 LP |
726 | <varlistentry> |
727 | <term><varname>StopWhenUnneeded=</varname></term> | |
728 | ||
729 | <listitem><para>Takes a boolean | |
730 | argument. If <option>true</option> | |
731 | this unit will be stopped when it is | |
732 | no longer used. Note that in order to | |
58c16a1a OÇ |
733 | minimize the work to be executed, |
734 | systemd will not stop units by default | |
11e29955 LP |
735 | unless they are conflicting with other |
736 | units, or the user explicitly | |
737 | requested their shut down. If this | |
58c16a1a | 738 | option is set, a unit will be |
11e29955 LP |
739 | automatically cleaned up if no other |
740 | active unit requires it. Defaults to | |
741 | <option>false</option>.</para></listitem> | |
742 | </varlistentry> | |
743 | ||
744 | <varlistentry> | |
b5e9dba8 LP |
745 | <term><varname>RefuseManualStart=</varname></term> |
746 | <term><varname>RefuseManualStop=</varname></term> | |
11e29955 LP |
747 | |
748 | <listitem><para>Takes a boolean | |
749 | argument. If <option>true</option> | |
58c16a1a | 750 | this unit can only be activated |
16dad32e | 751 | or deactivated indirectly. In |
b5e9dba8 | 752 | this case explicit start-up |
16dad32e | 753 | or termination requested by the |
b5e9dba8 | 754 | user is denied, however if it is |
16dad32e | 755 | started or stopped as a |
58c16a1a | 756 | dependency of another unit, start-up |
16dad32e | 757 | or termination will succeed. This |
b5e9dba8 LP |
758 | is mostly a safety feature to ensure |
759 | that the user does not accidentally | |
760 | activate units that are not intended | |
761 | to be activated explicitly, and not | |
762 | accidentally deactivate units that are | |
763 | not intended to be deactivated. | |
764 | These options default to | |
11e29955 LP |
765 | <option>false</option>.</para></listitem> |
766 | </varlistentry> | |
767 | ||
2528a7a6 LP |
768 | <varlistentry> |
769 | <term><varname>AllowIsolate=</varname></term> | |
770 | ||
771 | <listitem><para>Takes a boolean | |
772 | argument. If <option>true</option> | |
773 | this unit may be used with the | |
774 | <command>systemctl isolate</command> | |
775 | command. Otherwise this will be | |
776 | refused. It probably is a good idea to | |
777 | leave this disabled except for target | |
778 | units that shall be used similar to | |
779 | runlevels in SysV init systems, just | |
780 | as a precaution to avoid unusable | |
781 | system states. This option defaults to | |
782 | <option>false</option>.</para></listitem> | |
783 | </varlistentry> | |
784 | ||
62adf224 LP |
785 | <varlistentry> |
786 | <term><varname>DefaultDependencies=</varname></term> | |
787 | ||
788 | <listitem><para>Takes a boolean | |
789 | argument. If <option>true</option> | |
790 | (the default), a few default | |
791 | dependencies will implicitly be | |
792 | created for the unit. The actual | |
793 | dependencies created depend on the | |
794 | unit type. For example, for service | |
795 | units, these dependencies ensure that | |
796 | the service is started only after | |
797 | basic system initialization is | |
58c16a1a | 798 | completed and is properly terminated on |
62adf224 LP |
799 | system shutdown. See the respective |
800 | man pages for details. Generally, only | |
801 | services involved with early boot or | |
802 | late shutdown should set this option | |
803 | to <option>false</option>. It is | |
804 | highly recommended to leave this | |
805 | option enabled for the majority of | |
806 | common units. If set to | |
409dee2e | 807 | <option>false</option>, this option |
62adf224 LP |
808 | does not disable all implicit |
809 | dependencies, just non-essential | |
810 | ones.</para></listitem> | |
811 | </varlistentry> | |
812 | ||
b9975629 LP |
813 | <varlistentry> |
814 | <term><varname>JobTimeoutSec=</varname></term> | |
815 | ||
816 | <listitem><para>When clients are | |
817 | waiting for a job of this unit to | |
818 | complete, time out after the specified | |
819 | time. If this time limit is reached | |
820 | the job will be cancelled, the unit | |
821 | however will not change state or even | |
909f413d | 822 | enter the <literal>failed</literal> |
74ac3cbd MM |
823 | mode. This value defaults to 0 (job |
824 | timeouts disabled), except for device | |
825 | units. NB: this timeout is independent | |
826 | from any unit-specific timeout (for | |
827 | example, the timeout set with | |
b9975629 | 828 | <varname>Timeout=</varname> in service |
74ac3cbd MM |
829 | units) as the job timeout has no |
830 | effect on the unit itself, only on the | |
831 | job that might be pending for it. Or | |
832 | in other words: unit-specific timeouts | |
b9975629 LP |
833 | are useful to abort unit state |
834 | changes, and revert them. The job | |
835 | timeout set with this option however | |
74ac3cbd MM |
836 | is useful to abort only the job |
837 | waiting for the unit state to | |
838 | change.</para></listitem> | |
b9975629 LP |
839 | </varlistentry> |
840 | ||
52661efd LP |
841 | <varlistentry> |
842 | <term><varname>ConditionPathExists=</varname></term> | |
8092a428 | 843 | <term><varname>ConditionPathExistsGlob=</varname></term> |
c61e77d3 | 844 | <term><varname>ConditionPathIsDirectory=</varname></term> |
0d60602c | 845 | <term><varname>ConditionPathIsSymbolicLink=</varname></term> |
ab7f148f | 846 | <term><varname>ConditionPathIsMountPoint=</varname></term> |
d0516109 | 847 | <term><varname>ConditionPathIsReadWrite=</varname></term> |
36af55d9 | 848 | <term><varname>ConditionDirectoryNotEmpty=</varname></term> |
742a862b | 849 | <term><varname>ConditionFileNotEmpty=</varname></term> |
82e487c5 | 850 | <term><varname>ConditionFileIsExecutable=</varname></term> |
52661efd | 851 | <term><varname>ConditionKernelCommandLine=</varname></term> |
039655a4 | 852 | <term><varname>ConditionVirtualization=</varname></term> |
69528c31 | 853 | <term><varname>ConditionSecurity=</varname></term> |
62590f23 | 854 | <term><varname>ConditionCapability=</varname></term> |
c0d6e764 | 855 | <term><varname>ConditionHost=</varname></term> |
240dbaa4 | 856 | <term><varname>ConditionACPower=</varname></term> |
d257ddef | 857 | <term><varname>ConditionNull=</varname></term> |
52661efd LP |
858 | |
859 | <listitem><para>Before starting a unit | |
860 | verify that the specified condition is | |
c0d6e764 LP |
861 | true. If it is not true the starting |
862 | of the unit will be skipped, however | |
863 | all ordering dependencies of it are | |
864 | still respected. A failing condition | |
865 | will not result in the unit being | |
866 | moved into a failure state. The | |
867 | condition is checked at the time the | |
868 | queued start job is to be | |
869 | executed.</para> | |
870 | ||
871 | <para>With | |
52661efd | 872 | <varname>ConditionPathExists=</varname> |
c0d6e764 | 873 | a file existence condition is |
52661efd LP |
874 | checked before a unit is started. If |
875 | the specified absolute path name does | |
c0d6e764 LP |
876 | not exist the condition will |
877 | fail. If the absolute path name passed | |
878 | to | |
52661efd LP |
879 | <varname>ConditionPathExists=</varname> |
880 | is prefixed with an exclamation mark | |
909f413d | 881 | (<literal>!</literal>), the test is negated, and the unit |
418112a2 | 882 | is only started if the path does not |
c0d6e764 LP |
883 | exist.</para> |
884 | ||
885 | <para><varname>ConditionPathExistsGlob=</varname> | |
886 | is similar to | |
887 | <varname>ConditionPathExists=</varname>, | |
888 | but checks for the existence of at | |
889 | least one file or directory matching | |
890 | the specified globbing pattern.</para> | |
891 | ||
892 | <para><varname>ConditionPathIsDirectory=</varname> | |
ab7f148f LP |
893 | is similar to |
894 | <varname>ConditionPathExists=</varname> | |
895 | but verifies whether a certain path | |
8571962c | 896 | exists and is a |
c0d6e764 LP |
897 | directory.</para> |
898 | ||
899 | <para><varname>ConditionPathIsSymbolicLink=</varname> | |
0d60602c MS |
900 | is similar to |
901 | <varname>ConditionPathExists=</varname> | |
902 | but verifies whether a certain path | |
8095200d | 903 | exists and is a symbolic |
c0d6e764 LP |
904 | link.</para> |
905 | ||
906 | <para><varname>ConditionPathIsMountPoint=</varname> | |
ab7f148f LP |
907 | is similar to |
908 | <varname>ConditionPathExists=</varname> | |
909 | but verifies whether a certain path | |
910 | exists and is a mount | |
c0d6e764 LP |
911 | point.</para> |
912 | ||
913 | <para><varname>ConditionPathIsReadWrite=</varname> | |
d0516109 LP |
914 | is similar to |
915 | <varname>ConditionPathExists=</varname> | |
916 | but verifies whether the underlying | |
c0d6e764 | 917 | file system is readable and writable |
d0516109 | 918 | (i.e. not mounted |
c0d6e764 LP |
919 | read-only).</para> |
920 | ||
742a862b | 921 | <para><varname>ConditionDirectoryNotEmpty=</varname> |
ab7f148f LP |
922 | is similar to |
923 | <varname>ConditionPathExists=</varname> | |
924 | but verifies whether a certain path | |
742a862b LP |
925 | exists and is a non-empty |
926 | directory.</para> | |
c0d6e764 | 927 | |
742a862b | 928 | <para><varname>ConditionFileNotEmpty=</varname> |
c61e77d3 LP |
929 | is similar to |
930 | <varname>ConditionPathExists=</varname> | |
931 | but verifies whether a certain path | |
742a862b LP |
932 | exists and refers to a regular file |
933 | with a non-zero size.</para> | |
934 | ||
935 | <para><varname>ConditionFileIsExecutable=</varname> | |
936 | is similar to | |
937 | <varname>ConditionPathExists=</varname> | |
938 | but verifies whether a certain path | |
939 | exists, is a regular file and marked | |
940 | executable.</para> | |
c0d6e764 | 941 | |
742a862b | 942 | <para>Similar, |
52661efd LP |
943 | <varname>ConditionKernelCommandLine=</varname> |
944 | may be used to check whether a | |
945 | specific kernel command line option is | |
946 | set (or if prefixed with the | |
947 | exclamation mark unset). The argument | |
948 | must either be a single word, or an | |
5471472d | 949 | assignment (i.e. two words, separated |
909f413d | 950 | <literal>=</literal>). In the former |
d257ddef LP |
951 | case the kernel command line is |
952 | searched for the word appearing as is, | |
953 | or as left hand side of an | |
954 | assignment. In the latter case the | |
955 | exact assignment is looked for with | |
956 | right and left hand side | |
c0d6e764 LP |
957 | matching.</para> |
958 | ||
959 | <para><varname>ConditionVirtualization=</varname> | |
039655a4 LP |
960 | may be used to check whether the |
961 | system is executed in a virtualized | |
962 | environment and optionally test | |
963 | whether it is a specific | |
964 | implementation. Takes either boolean | |
267632f0 | 965 | value to check if being executed in |
8095200d LP |
966 | any virtualized environment, or one of |
967 | <varname>vm</varname> and | |
62590f23 | 968 | <varname>container</varname> to test |
c0d6e764 | 969 | against a generic type of |
62590f23 | 970 | virtualization solution, or one of |
039655a4 LP |
971 | <varname>qemu</varname>, |
972 | <varname>kvm</varname>, | |
973 | <varname>vmware</varname>, | |
974 | <varname>microsoft</varname>, | |
975 | <varname>oracle</varname>, | |
976 | <varname>xen</varname>, | |
8095200d LP |
977 | <varname>bochs</varname>, |
978 | <varname>chroot</varname>, | |
7080ea16 | 979 | <varname>uml</varname>, |
65bc2c21 LP |
980 | <varname>openvz</varname>, |
981 | <varname>lxc</varname>, | |
7d39db92 | 982 | <varname>lxc-libvirt</varname>, |
d0516109 LP |
983 | <varname>systemd-nspawn</varname> to |
984 | test against a specific | |
985 | implementation. If multiple | |
986 | virtualization technologies are nested | |
987 | only the innermost is considered. The | |
988 | test may be negated by prepending an | |
c0d6e764 LP |
989 | exclamation mark.</para> |
990 | ||
991 | <para><varname>ConditionSecurity=</varname> | |
8092a428 LP |
992 | may be used to check whether the given |
993 | security module is enabled on the | |
9d995d54 | 994 | system. Currently the recognized values |
b62ee524 | 995 | values are <varname>selinux</varname>, |
9d995d54 AK |
996 | <varname>apparmor</varname>, |
997 | <varname>ima</varname> and | |
b62ee524 | 998 | <varname>smack</varname>. |
8092a428 | 999 | The test may be negated by prepending |
62590f23 | 1000 | an exclamation |
c0d6e764 LP |
1001 | mark.</para> |
1002 | ||
1003 | <para><varname>ConditionCapability=</varname> | |
62590f23 LP |
1004 | may be used to check whether the given |
1005 | capability exists in the capability | |
1006 | bounding set of the service manager | |
1007 | (i.e. this does not check whether | |
1008 | capability is actually available in | |
1009 | the permitted or effective sets, see | |
1010 | <citerefentry><refentrytitle>capabilities</refentrytitle><manvolnum>7</manvolnum></citerefentry> | |
1011 | for details). Pass a capability name | |
1012 | such as <literal>CAP_MKNOD</literal>, | |
1013 | possibly prefixed with an exclamation | |
c0d6e764 LP |
1014 | mark to negate the check.</para> |
1015 | ||
1016 | <para><varname>ConditionHost=</varname> | |
1017 | may be used to match against the | |
e9dd9f95 JSJ |
1018 | hostname or machine ID of the |
1019 | host. This either takes a hostname | |
c0d6e764 LP |
1020 | string (optionally with shell style |
1021 | globs) which is tested against the | |
e9dd9f95 | 1022 | locally set hostname as returned by |
c0d6e764 LP |
1023 | <citerefentry><refentrytitle>gethostname</refentrytitle><manvolnum>2</manvolnum></citerefentry>, |
1024 | or a machine ID formatted as string | |
1025 | (see | |
1026 | <citerefentry><refentrytitle>machine-id</refentrytitle><manvolnum>5</manvolnum></citerefentry>). | |
1027 | The test may be negated by prepending | |
1028 | an exclamation mark.</para> | |
1029 | ||
240dbaa4 | 1030 | <para><varname>ConditionACPower=</varname> |
e711d102 TA |
1031 | may be used to check whether the |
1032 | system has AC power, or is exclusively | |
240dbaa4 LP |
1033 | battery powered at the time of |
1034 | activation of the unit. This takes a | |
1035 | boolean argument. If set to | |
1036 | <varname>true</varname> the condition | |
1037 | will hold only if at least one AC | |
1038 | connector of the system is connected | |
1039 | to a power source, or if no AC | |
1040 | connectors are known. Conversely, if | |
1041 | set to <varname>false</varname> the | |
1042 | condition will hold only if there is | |
1043 | at least one AC connector known and | |
1044 | all AC connectors are disconnected | |
1045 | from a power source.</para> | |
1046 | ||
c0d6e764 | 1047 | <para>Finally, |
d257ddef LP |
1048 | <varname>ConditionNull=</varname> may |
1049 | be used to add a constant condition | |
1050 | check value to the unit. It takes a | |
1051 | boolean argument. If set to | |
1052 | <varname>false</varname> the condition | |
1053 | will always fail, otherwise | |
c0d6e764 LP |
1054 | succeed.</para> |
1055 | ||
1056 | <para>If multiple conditions are | |
039655a4 | 1057 | specified the unit will be executed if |
267632f0 LP |
1058 | all of them apply (i.e. a logical AND |
1059 | is applied). Condition checks can be | |
1060 | prefixed with a pipe symbol (|) in | |
1061 | which case a condition becomes a | |
1062 | triggering condition. If at least one | |
1063 | triggering condition is defined for a | |
1064 | unit then the unit will be executed if | |
1065 | at least one of the triggering | |
1066 | conditions apply and all of the | |
1067 | non-triggering conditions. If you | |
1068 | prefix an argument with the pipe | |
1069 | symbol and an exclamation mark the | |
1070 | pipe symbol must be passed first, the | |
0d60602c MS |
1071 | exclamation second. Except for |
1072 | <varname>ConditionPathIsSymbolicLink=</varname>, | |
74051b9b LP |
1073 | all path checks follow symlinks. If |
1074 | any of these options is assigned the | |
1075 | empty string the list of conditions is | |
1076 | reset completely, all previous | |
1077 | condition settings (of any kind) will | |
1078 | have no effect.</para></listitem> | |
52661efd | 1079 | </varlistentry> |
e2130f18 | 1080 | |
1b64d026 LP |
1081 | <varlistentry> |
1082 | <term><varname>SourcePath=</varname></term> | |
1083 | <listitem><para>A path to a | |
1084 | configuration file this unit has been | |
1085 | generated from. This is primarily | |
1086 | useful for implementation of generator | |
1087 | tools that convert configuration from | |
1088 | an external configuration file format | |
1089 | into native unit files. Thus | |
1090 | functionality should not be used in | |
1091 | normal units.</para></listitem> | |
1092 | </varlistentry> | |
d1ab0ca0 | 1093 | </variablelist> |
771610b0 LP |
1094 | |
1095 | <para>Unit file may include a [Install] section, which | |
1096 | carries installation information for the unit. This | |
1097 | section is not interpreted by | |
1098 | <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry> | |
1099 | during runtime. It is used exclusively by the | |
ee5762e3 LP |
1100 | <command>enable</command> and |
1101 | <command>disable</command> commands of the | |
1102 | <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry> | |
11e29955 | 1103 | tool during installation of a unit:</para> |
771610b0 | 1104 | |
ccc9a4f9 | 1105 | <variablelist class='unit-directives'> |
771610b0 LP |
1106 | <varlistentry> |
1107 | <term><varname>Alias=</varname></term> | |
1108 | ||
0a715d97 | 1109 | <listitem><para>Additional names this |
771610b0 LP |
1110 | unit shall be installed under. The |
1111 | names listed here must have the same | |
1112 | suffix (i.e. type) as the unit file | |
1113 | name. This option may be specified | |
1114 | more than once, in which case all | |
1115 | listed names are used. At installation | |
af62c704 | 1116 | time, |
ee5762e3 | 1117 | <command>systemctl enable</command> |
771610b0 | 1118 | will create symlinks from these names |
e9dd9f95 | 1119 | to the unit filename.</para></listitem> |
11e29955 LP |
1120 | </varlistentry> |
1121 | ||
1122 | <varlistentry> | |
1123 | <term><varname>WantedBy=</varname></term> | |
78d54bd4 | 1124 | <term><varname>RequiredBy=</varname></term> |
11e29955 | 1125 | |
3eb13957 ZJS |
1126 | <listitem><para>A symbolic link is |
1127 | created in the | |
1128 | <filename>.wants/</filename> or | |
fbce1139 | 1129 | <filename>.requires/</filename> directory |
3eb13957 ZJS |
1130 | of the listed unit when this unit is |
1131 | activated by <command>systemctl | |
1132 | enable</command>. This has the effect | |
1133 | that a dependency of type | |
1134 | <varname>Wants=</varname> or | |
1135 | <varname>Requires=</varname> is added | |
1136 | from the listed unit to the current | |
1137 | unit. The primary result is that the | |
1138 | current unit will be started when the | |
1139 | listed unit is started. See the | |
1140 | description of | |
1141 | <varname>Wants=</varname> and | |
1142 | <varname>Requires=</varname> in the | |
1143 | [Unit] section for details.</para> | |
1144 | ||
1145 | <para><command>WantedBy=foo.service</command> | |
11e29955 LP |
1146 | in a service |
1147 | <filename>bar.service</filename> is | |
1148 | mostly equivalent to | |
1149 | <command>Alias=foo.service.wants/bar.service</command> | |
3eb13957 ZJS |
1150 | in the same file. In case of template |
1151 | units, <command>systemctl enable</command> | |
1152 | must be called with an instance name, and | |
1153 | this instance will be added to the | |
1154 | <filename>.wants/</filename> or | |
1155 | <filename>.requires/</filename> list | |
1156 | of the listed unit. | |
1157 | E.g. <command>WantedBy=getty.target</command> | |
1158 | in a service | |
1159 | <filename>getty@.service</filename> | |
1160 | will result in <command>systemctl | |
1161 | enable getty@tty2.service</command> | |
1162 | creating a | |
1163 | <filename>getty.target.wants/getty@tty2.service</filename> | |
1164 | link to <filename>getty@.service</filename>. | |
1165 | </para></listitem> | |
11e29955 LP |
1166 | </varlistentry> |
1167 | ||
1168 | <varlistentry> | |
1169 | <term><varname>Also=</varname></term> | |
1170 | ||
1171 | <listitem><para>Additional units to | |
a7be37a5 LP |
1172 | install/deinstall when this unit is |
1173 | installed/deinstalled. If the user | |
1174 | requests installation/deinstallation | |
1175 | of a unit with this option configured, | |
ee5762e3 | 1176 | <command>systemctl enable</command> |
a7be37a5 LP |
1177 | and <command>systemctl |
1178 | disable</command> will automatically | |
1179 | install/uninstall units listed in this option as | |
11e29955 | 1180 | well.</para></listitem> |
771610b0 LP |
1181 | </varlistentry> |
1182 | </variablelist> | |
1183 | ||
7584d236 | 1184 | <para>The following specifiers are interpreted in the |
6aaa8c2f | 1185 | Install section: %n, %N, %p, %i, %U, %u, %m, %H, %b, %v. |
7584d236 ZJS |
1186 | For their meaning see the next section. |
1187 | </para> | |
d1ab0ca0 LP |
1188 | </refsect1> |
1189 | ||
8afbb8e1 LP |
1190 | <refsect1> |
1191 | <title>Specifiers</title> | |
1192 | ||
1193 | <para>Many settings resolve specifiers which may be | |
1194 | used to write generic unit files referring to runtime | |
1195 | or unit parameters that are replaced when the unit | |
1196 | files are loaded. The following specifiers are | |
1197 | understood:</para> | |
1198 | ||
1199 | <table> | |
1200 | <title>Specifiers available in unit files</title> | |
1201 | <tgroup cols='3' align='left' colsep='1' rowsep='1'> | |
1202 | <colspec colname="spec" /> | |
1203 | <colspec colname="mean" /> | |
1204 | <colspec colname="detail" /> | |
1205 | <thead> | |
1206 | <row> | |
1207 | <entry>Specifier</entry> | |
1208 | <entry>Meaning</entry> | |
1209 | <entry>Details</entry> | |
1210 | </row> | |
1211 | </thead> | |
1212 | <tbody> | |
1213 | <row> | |
1214 | <entry><literal>%n</literal></entry> | |
1215 | <entry>Full unit name</entry> | |
1216 | <entry></entry> | |
1217 | </row> | |
1218 | <row> | |
1219 | <entry><literal>%N</literal></entry> | |
1220 | <entry>Unescaped full unit name</entry> | |
1221 | <entry></entry> | |
1222 | </row> | |
1223 | <row> | |
1224 | <entry><literal>%p</literal></entry> | |
1225 | <entry>Prefix name</entry> | |
1226 | <entry>For instantiated units this refers to the string before the @. For non-instantiated units this refers to to the name of the unit with the type suffix removed.</entry> | |
1227 | </row> | |
1228 | <row> | |
1229 | <entry><literal>%P</literal></entry> | |
1230 | <entry>Unescaped prefix name</entry> | |
1231 | <entry></entry> | |
1232 | </row> | |
1233 | <row> | |
1234 | <entry><literal>%i</literal></entry> | |
1235 | <entry>Instance name</entry> | |
05cc7267 | 1236 | <entry>For instantiated units: this is the string between the <literal>@</literal> character and the suffix.</entry> |
8afbb8e1 LP |
1237 | </row> |
1238 | <row> | |
1239 | <entry><literal>%I</literal></entry> | |
1240 | <entry>Unescaped instance name</entry> | |
1241 | <entry></entry> | |
1242 | </row> | |
1243 | <row> | |
1244 | <entry><literal>%f</literal></entry> | |
e9dd9f95 | 1245 | <entry>Unescaped filename</entry> |
0df2d38a | 1246 | <entry>This is either the unescaped instance name (if applicable) with <filename>/</filename> prepended (if applicable), or the prefix name similarly prepended with <filename>/</filename>.</entry> |
8afbb8e1 LP |
1247 | </row> |
1248 | <row> | |
1249 | <entry><literal>%c</literal></entry> | |
1250 | <entry>Control group path of the unit</entry> | |
1251 | <entry></entry> | |
1252 | </row> | |
1253 | <row> | |
1254 | <entry><literal>%r</literal></entry> | |
0df2d38a LP |
1255 | <entry>Root control group path where units are placed.</entry> |
1256 | <entry>For system instances this usually resolves to <filename>/system</filename>, except in containers, where the path might be prefixed with the container's root control group.</entry> | |
8afbb8e1 LP |
1257 | </row> |
1258 | <row> | |
1259 | <entry><literal>%R</literal></entry> | |
0df2d38a LP |
1260 | <entry>Parent directory of the control group path where units are placed.</entry> |
1261 | <entry>For system instances this usually resolves to <filename>/</filename>, except in containers, where this resolves to the container's root directory. This specifier is particularly useful in the <varname>ControlGroup=</varname> setting (see <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>).</entry> | |
8afbb8e1 LP |
1262 | </row> |
1263 | <row> | |
1264 | <entry><literal>%t</literal></entry> | |
1265 | <entry>Runtime socket dir</entry> | |
1266 | <entry>This is either <filename>/run</filename> (for the system manager) or <literal>$XDG_RUNTIME_DIR</literal> (for user managers).</entry> | |
1267 | </row> | |
1268 | <row> | |
1269 | <entry><literal>%u</literal></entry> | |
1270 | <entry>User name</entry> | |
1271 | <entry>This is the name of the configured user of the unit, or (if none is set) the user running the systemd instance.</entry> | |
1272 | </row> | |
1273 | <row> | |
1274 | <entry><literal>%U</literal></entry> | |
1275 | <entry>User UID</entry> | |
1276 | <entry>This is the UID of the configured user of the unit, or (if none is set) the user running the systemd instance.</entry> | |
1277 | </row> | |
1278 | <row> | |
1279 | <entry><literal>%h</literal></entry> | |
1280 | <entry>User home directory</entry> | |
1281 | <entry>This is the home directory of the configured user of the unit, or (if none is set) the user running the systemd instance.</entry> | |
1282 | </row> | |
1283 | <row> | |
1284 | <entry><literal>%s</literal></entry> | |
1285 | <entry>User shell</entry> | |
0df2d38a | 1286 | <entry>This is the shell of the configured user of the unit, or (if none is set) the user running the systemd instance. If the user is <literal>root</literal> (UID equal to 0), the shell configured in account database is ignored and <filename>/bin/sh</filename> is always used.</entry> |
8afbb8e1 LP |
1287 | </row> |
1288 | <row> | |
1289 | <entry><literal>%m</literal></entry> | |
1290 | <entry>Machine ID</entry> | |
1291 | <entry>The machine ID of the running system, formatted as string. See <citerefentry><refentrytitle>machine-id</refentrytitle><manvolnum>5</manvolnum></citerefentry> for more information.</entry> | |
1292 | </row> | |
1293 | <row> | |
1294 | <entry><literal>%b</literal></entry> | |
1295 | <entry>Boot ID</entry> | |
1296 | <entry>The boot ID of the running system, formatted as string. See <citerefentry><refentrytitle>random</refentrytitle><manvolnum>4</manvolnum></citerefentry> for more information.</entry> | |
1297 | </row> | |
1298 | <row> | |
1299 | <entry><literal>%H</literal></entry> | |
1300 | <entry>Host name</entry> | |
e9dd9f95 | 1301 | <entry>The hostname of the running system.</entry> |
8afbb8e1 | 1302 | </row> |
6aaa8c2f ZJS |
1303 | <row> |
1304 | <entry><literal>%v</literal></entry> | |
1305 | <entry>Kernel release</entry> | |
1306 | <entry>Identical to <command>uname -r</command> output.</entry> | |
1307 | </row> | |
599391d8 ZJS |
1308 | <row> |
1309 | <entry><literal>%%</literal></entry> | |
1310 | <entry>Escaped %</entry> | |
1311 | <entry>Single percent sign.</entry> | |
1312 | </row> | |
8afbb8e1 LP |
1313 | </tbody> |
1314 | </tgroup> | |
1315 | </table> | |
1316 | </refsect1> | |
1317 | ||
d1ab0ca0 | 1318 | <refsect1> |
160cd5c9 LP |
1319 | <title>See Also</title> |
1320 | <para> | |
1321 | <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>, | |
771610b0 | 1322 | <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>8</manvolnum></citerefentry>, |
771610b0 LP |
1323 | <citerefentry><refentrytitle>systemd.special</refentrytitle><manvolnum>7</manvolnum></citerefentry>, |
1324 | <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
1325 | <citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
1326 | <citerefentry><refentrytitle>systemd.device</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
1327 | <citerefentry><refentrytitle>systemd.mount</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
1328 | <citerefentry><refentrytitle>systemd.automount</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
1329 | <citerefentry><refentrytitle>systemd.swap</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
1330 | <citerefentry><refentrytitle>systemd.target</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
1331 | <citerefentry><refentrytitle>systemd.path</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
5f2ee303 | 1332 | <citerefentry><refentrytitle>systemd.timer</refentrytitle><manvolnum>5</manvolnum></citerefentry>, |
62590f23 | 1333 | <citerefentry><refentrytitle>systemd.snapshot</refentrytitle><manvolnum>5</manvolnum></citerefentry>, |
e73eebfd LP |
1334 | <citerefentry><refentrytitle>systemd.scope</refentrytitle><manvolnum>5</manvolnum></citerefentry>, |
1335 | <citerefentry><refentrytitle>systemd.slice</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
7a529f63 | 1336 | <citerefentry><refentrytitle>systemd.time</refentrytitle><manvolnum>7</manvolnum></citerefentry>, |
9cc2c8b7 | 1337 | <citerefentry><refentrytitle>capabilities</refentrytitle><manvolnum>7</manvolnum></citerefentry>, |
6aaa8c2f ZJS |
1338 | <citerefentry><refentrytitle>systemd.directives</refentrytitle><manvolnum>7</manvolnum></citerefentry>, |
1339 | <citerefentry><refentrytitle>uname</refentrytitle><manvolnum>1</manvolnum></citerefentry> | |
160cd5c9 | 1340 | </para> |
d1ab0ca0 LP |
1341 | </refsect1> |
1342 | ||
1343 | </refentry> |