]>
Commit | Line | Data |
---|---|---|
c129bd5d | 1 | <?xml version='1.0'?> <!--*- Mode: nxml; nxml-child-indent: 2; indent-tabs-mode: nil -*--> |
d1ab0ca0 | 2 | <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" |
798d3a52 | 3 | "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [ |
1a13e31d ZJS |
4 | <!ENTITY % entities SYSTEM "custom-entities.ent" > |
5 | %entities; | |
6 | ]> | |
d1ab0ca0 LP |
7 | |
8 | <!-- | |
572eb058 ZJS |
9 | SPDX-License-Identifier: LGPL-2.1+ |
10 | ||
d1ab0ca0 LP |
11 | This file is part of systemd. |
12 | ||
13 | Copyright 2010 Lennart Poettering | |
14 | ||
15 | systemd is free software; you can redistribute it and/or modify it | |
5430f7f2 LP |
16 | under the terms of the GNU Lesser General Public License as published by |
17 | the Free Software Foundation; either version 2.1 of the License, or | |
d1ab0ca0 LP |
18 | (at your option) any later version. |
19 | ||
20 | systemd is distributed in the hope that it will be useful, but | |
21 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
22 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
5430f7f2 | 23 | Lesser General Public License for more details. |
d1ab0ca0 | 24 | |
5430f7f2 | 25 | You should have received a copy of the GNU Lesser General Public License |
d1ab0ca0 LP |
26 | along with systemd; If not, see <http://www.gnu.org/licenses/>. |
27 | --> | |
28 | ||
29 | <refentry id="systemd.unit"> | |
30 | ||
798d3a52 ZJS |
31 | <refentryinfo> |
32 | <title>systemd.unit</title> | |
33 | <productname>systemd</productname> | |
34 | ||
35 | <authorgroup> | |
36 | <author> | |
37 | <contrib>Developer</contrib> | |
38 | <firstname>Lennart</firstname> | |
39 | <surname>Poettering</surname> | |
40 | <email>lennart@poettering.net</email> | |
41 | </author> | |
42 | </authorgroup> | |
43 | </refentryinfo> | |
44 | ||
45 | <refmeta> | |
46 | <refentrytitle>systemd.unit</refentrytitle> | |
47 | <manvolnum>5</manvolnum> | |
48 | </refmeta> | |
49 | ||
50 | <refnamediv> | |
51 | <refname>systemd.unit</refname> | |
52 | <refpurpose>Unit configuration</refpurpose> | |
53 | </refnamediv> | |
54 | ||
55 | <refsynopsisdiv> | |
56 | <para><filename><replaceable>service</replaceable>.service</filename>, | |
57 | <filename><replaceable>socket</replaceable>.socket</filename>, | |
58 | <filename><replaceable>device</replaceable>.device</filename>, | |
59 | <filename><replaceable>mount</replaceable>.mount</filename>, | |
60 | <filename><replaceable>automount</replaceable>.automount</filename>, | |
61 | <filename><replaceable>swap</replaceable>.swap</filename>, | |
62 | <filename><replaceable>target</replaceable>.target</filename>, | |
63 | <filename><replaceable>path</replaceable>.path</filename>, | |
64 | <filename><replaceable>timer</replaceable>.timer</filename>, | |
798d3a52 ZJS |
65 | <filename><replaceable>slice</replaceable>.slice</filename>, |
66 | <filename><replaceable>scope</replaceable>.scope</filename></para> | |
67 | ||
12b42c76 | 68 | <para><literallayout><filename>/etc/systemd/system/*</filename> |
13219b7f | 69 | <filename>/run/systemd/system/*</filename> |
12b42c76 | 70 | <filename>/usr/lib/systemd/system/*</filename> |
f6e1bd2c | 71 | <filename>…</filename> |
798d3a52 | 72 | </literallayout></para> |
13219b7f | 73 | |
f6e1bd2c | 74 | <para><literallayout><filename>~/.config/systemd/user/*</filename> |
12b42c76 | 75 | <filename>/etc/systemd/user/*</filename> |
aa08982d | 76 | <filename>$XDG_RUNTIME_DIR/systemd/user/*</filename> |
13219b7f | 77 | <filename>/run/systemd/user/*</filename> |
f6e1bd2c | 78 | <filename>~/.local/share/systemd/user/*</filename> |
12b42c76 | 79 | <filename>/usr/lib/systemd/user/*</filename> |
f6e1bd2c | 80 | <filename>…</filename> |
798d3a52 ZJS |
81 | </literallayout></para> |
82 | </refsynopsisdiv> | |
83 | ||
84 | <refsect1> | |
85 | <title>Description</title> | |
86 | ||
87 | <para>A unit configuration file encodes information about a | |
88 | service, a socket, a device, a mount point, an automount point, a | |
89 | swap file or partition, a start-up target, a watched file system | |
90 | path, a timer controlled and supervised by | |
91 | <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>, | |
36b4a7ba | 92 | a resource management slice or |
798d3a52 ZJS |
93 | a group of externally created processes. The syntax is inspired by |
94 | <ulink | |
95 | url="http://standards.freedesktop.org/desktop-entry-spec/latest/">XDG | |
96 | Desktop Entry Specification</ulink> <filename>.desktop</filename> | |
97 | files, which are in turn inspired by Microsoft Windows | |
98 | <filename>.ini</filename> files.</para> | |
99 | ||
100 | <para>This man page lists the common configuration options of all | |
101 | the unit types. These options need to be configured in the [Unit] | |
102 | or [Install] sections of the unit files.</para> | |
103 | ||
104 | <para>In addition to the generic [Unit] and [Install] sections | |
105 | described here, each unit may have a type-specific section, e.g. | |
106 | [Service] for a service unit. See the respective man pages for | |
107 | more 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>, | |
36b4a7ba | 117 | <citerefentry><refentrytitle>systemd.slice</refentrytitle><manvolnum>5</manvolnum></citerefentry>, |
798d3a52 ZJS |
118 | <citerefentry><refentrytitle>systemd.scope</refentrytitle><manvolnum>5</manvolnum></citerefentry>. |
119 | </para> | |
120 | ||
121 | <para>Various settings are allowed to be specified more than once, | |
122 | in which case the interpretation depends on the setting. Often, | |
123 | multiple settings form a list, and setting to an empty value | |
124 | "resets", which means that previous assignments are ignored. When | |
125 | this is allowed, it is mentioned in the description of the | |
126 | setting. Note that using multiple assignments to the same value | |
127 | makes the unit file incompatible with parsers for the XDG | |
128 | <filename>.desktop</filename> file format.</para> | |
129 | ||
130 | <para>Unit files are loaded from a set of paths determined during | |
131 | compilation, described in the next section.</para> | |
132 | ||
133 | <para>Unit files may contain additional options on top of those | |
134 | listed here. If systemd encounters an unknown option, it will | |
135 | write a warning log message but continue loading the unit. If an | |
136 | option or section name is prefixed with <option>X-</option>, it is | |
137 | ignored completely by systemd. Options within an ignored section | |
138 | do not need the prefix. Applications may use this to include | |
139 | additional information in the unit files.</para> | |
140 | ||
141 | <para>Boolean arguments used in unit files can be written in | |
142 | various formats. For positive settings the strings | |
143 | <option>1</option>, <option>yes</option>, <option>true</option> | |
144 | and <option>on</option> are equivalent. For negative settings, the | |
145 | strings <option>0</option>, <option>no</option>, | |
146 | <option>false</option> and <option>off</option> are | |
147 | equivalent.</para> | |
148 | ||
bac150e9 ZJS |
149 | <para>Time span values encoded in unit files can be written in various formats. A stand-alone |
150 | number specifies a time in seconds. If suffixed with a time unit, the unit is honored. A | |
151 | concatenation of multiple values with units is supported, in which case the values are added | |
152 | up. Example: <literal>50</literal> refers to 50 seconds; <literal>2min 200ms</literal> refers to | |
153 | 2 minutes and 200 milliseconds, i.e. 120200 ms. The following time units are understood: | |
154 | <literal>s</literal>, <literal>min</literal>, <literal>h</literal>, <literal>d</literal>, | |
d923e42e | 155 | <literal>w</literal>, <literal>ms</literal>, <literal>us</literal>. For details see |
798d3a52 ZJS |
156 | <citerefentry><refentrytitle>systemd.time</refentrytitle><manvolnum>7</manvolnum></citerefentry>.</para> |
157 | ||
bac150e9 ZJS |
158 | <para>Empty lines and lines starting with <literal>#</literal> or <literal>;</literal> are |
159 | ignored. This may be used for commenting. Lines ending in a backslash are concatenated with the | |
160 | following line while reading and the backslash is replaced by a space character. This may be | |
161 | used to wrap long lines.</para> | |
162 | ||
163 | <para>Units can be aliased (have an alternative name), by creating a symlink from the new name | |
164 | to the existing name in one of the unit search paths. For example, | |
165 | <filename>systemd-networkd.service</filename> has the alias | |
166 | <filename>dbus-org.freedesktop.network1.service</filename>, created during installation as the | |
167 | symlink <filename>/usr/lib/systemd/system/dbus-org.freedesktop.network1.service</filename>. In | |
168 | addition, unit files may specify aliases through the <varname>Alias=</varname> directive in the | |
169 | [Install] section; those aliases are only effective when the unit is enabled. When the unit is | |
170 | enabled, symlinks will be created for those names, and removed when the unit is disabled. For | |
171 | example, <filename>reboot.target</filename> specifies | |
172 | <varname>Alias=ctrl-alt-del.target</varname>, so when enabled it will be invoked whenever | |
173 | CTRL+ALT+DEL is pressed. Alias names may be used in commands like <command>enable</command>, | |
174 | <command>disable</command>, <command>start</command>, <command>stop</command>, | |
175 | <command>status</command>, …, and in unit dependency directives <varname>Wants=</varname>, | |
176 | <varname>Requires=</varname>, <varname>Before=</varname>, <varname>After=</varname>, …, with the | |
177 | limitation that aliases specified through <varname>Alias=</varname> are only effective when the | |
178 | unit is enabled. Aliases cannot be used with the <command>preset</command> command.</para> | |
179 | ||
180 | <para>Along with a unit file <filename>foo.service</filename>, the directory | |
181 | <filename>foo.service.wants/</filename> may exist. All unit files symlinked from such a | |
182 | directory are implicitly added as dependencies of type <varname>Wants=</varname> to the unit. | |
183 | This is useful to hook units into the start-up of other units, without having to modify their | |
184 | unit files. For details about the semantics of <varname>Wants=</varname>, see below. The | |
185 | preferred way to create symlinks in the <filename>.wants/</filename> directory of a unit file is | |
186 | with the <command>enable</command> command of the | |
798d3a52 | 187 | <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry> |
bac150e9 ZJS |
188 | tool which reads information from the [Install] section of unit files (see below). A similar |
189 | functionality exists for <varname>Requires=</varname> type dependencies as well, the directory | |
190 | suffix is <filename>.requires/</filename> in this case.</para> | |
798d3a52 | 191 | |
be73bb48 | 192 | <para>Along with a unit file <filename>foo.service</filename>, a "drop-in" directory |
bac150e9 ZJS |
193 | <filename>foo.service.d/</filename> may exist. All files with the suffix |
194 | <literal>.conf</literal> from this directory will be parsed after the file itself is | |
195 | parsed. This is useful to alter or add configuration settings for a unit, without having to | |
196 | modify unit files. Each drop-in file must have appropriate section headers. Note that for | |
197 | instantiated units, this logic will first look for the instance <literal>.d/</literal> | |
198 | subdirectory and read its <literal>.conf</literal> files, followed by the template | |
caa45f5b | 199 | <literal>.d/</literal> subdirectory and the <literal>.conf</literal> files there.</para> |
bac150e9 ZJS |
200 | |
201 | <para>In addition to <filename>/etc/systemd/system</filename>, the drop-in <literal>.d</literal> | |
202 | directories for system services can be placed in <filename>/usr/lib/systemd/system</filename> or | |
203 | <filename>/run/systemd/system</filename> directories. Drop-in files in <filename>/etc</filename> | |
204 | take precedence over those in <filename>/run</filename> which in turn take precedence over those | |
205 | in <filename>/usr/lib</filename>. Drop-in files under any of these directories take precedence | |
8331eaab LW |
206 | over unit files wherever located. Multiple drop-in files with different names are applied in |
207 | lexicographic order, regardless of which of the directories they reside in.</para> | |
bac150e9 ZJS |
208 | |
209 | <!-- Note that we do not document .include here, as we consider it mostly obsolete, and want | |
210 | people to use .d/ drop-ins instead. --> | |
798d3a52 | 211 | |
bbe0b4a8 JL |
212 | <para>Note that while systemd offers a flexible dependency system |
213 | between units it is recommended to use this functionality only | |
214 | sparingly and instead rely on techniques such as bus-based or | |
215 | socket-based activation which make dependencies implicit, | |
216 | resulting in a both simpler and more flexible system.</para> | |
217 | ||
798d3a52 ZJS |
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 | file system. If that yields no success and the unit | |
224 | name contains an <literal>@</literal> character, systemd will look for a | |
225 | unit template that shares the same name but with the | |
226 | instance string (i.e. the part between the <literal>@</literal> character | |
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 | |
232 | it is found.</para> | |
233 | ||
234 | <para>To refer to the instance string from within the | |
235 | configuration file you may use the special <literal>%i</literal> | |
236 | specifier in many of the configuration options. See below for | |
237 | details.</para> | |
238 | ||
239 | <para>If a unit file is empty (i.e. has the file size 0) or is | |
240 | symlinked to <filename>/dev/null</filename>, its configuration | |
241 | will not be loaded and it appears with a load state of | |
242 | <literal>masked</literal>, and cannot be activated. Use this as an | |
243 | effective way to fully disable a unit, making it impossible to | |
244 | start it even manually.</para> | |
245 | ||
246 | <para>The unit file format is covered by the | |
247 | <ulink | |
28a0ad81 | 248 | url="https://www.freedesktop.org/wiki/Software/systemd/InterfaceStabilityPromise">Interface |
798d3a52 ZJS |
249 | Stability Promise</ulink>.</para> |
250 | ||
251 | </refsect1> | |
252 | ||
2651d037 LP |
253 | <refsect1> |
254 | <title>String Escaping for Inclusion in Unit Names</title> | |
255 | ||
256 | <para>Sometimes it is useful to convert arbitrary strings into unit names. To facilitate this, a method of string | |
257 | escaping is used, in order to map strings containing arbitrary byte values (except NUL) into valid unit names and | |
258 | their restricted character set. A common special case are unit names that reflect paths to objects in the file | |
259 | system hierarchy. Example: a device unit <filename>dev-sda.device</filename> refers to a device with the device | |
260 | node <filename noindex='true'>/dev/sda</filename> in the file system.</para> | |
261 | ||
262 | <para>The escaping algorithm operates as follows: given a string, any <literal>/</literal> character is replaced by | |
263 | <literal>-</literal>, and all other characters which are not ASCII alphanumerics or <literal>_</literal> are | |
264 | replaced by C-style <literal>\x2d</literal> escapes. In addition, <literal>.</literal> is replaced with such a | |
265 | C-style escape when it would appear as the first character in the escaped string.</para> | |
266 | ||
267 | <para>When the input qualifies as absolute file system path, this algorithm is extended slightly: the path to the | |
268 | root directory <literal>/</literal> is encoded as single dash <literal>-</literal>. In addition, any leading, | |
269 | trailing or duplicate <literal>/</literal> characters are removed from the string before transformation. Example: | |
270 | <filename>/foo//bar/baz/</filename> becomes <literal>foo-bar-baz</literal>.</para> | |
271 | ||
272 | <para>This escaping is fully reversible, as long as it is known whether the escaped string was a path (the | |
273 | unescaping results are different for paths and non-path strings). The | |
274 | <citerefentry><refentrytitle>systemd-escape</refentrytitle><manvolnum>1</manvolnum></citerefentry> command may be | |
275 | used to apply and reverse escaping on arbitrary strings. Use <command>systemd-escape --path</command> to escape | |
276 | path strings, and <command>systemd-escape</command> without <option>--path</option> otherwise.</para> | |
277 | </refsect1> | |
278 | ||
c129bd5d | 279 | <refsect1> |
45f09f93 JL |
280 | <title>Implicit Dependencies</title> |
281 | ||
282 | <para>A number of unit dependencies are implicitly established, | |
283 | depending on unit type and unit configuration. These implicit | |
284 | dependencies can make unit configuration file cleaner. For the | |
285 | implicit dependencies in each unit type, please refer to | |
286 | section "Implicit Dependencies" in respective man pages.</para> | |
287 | ||
288 | <para>For example, service units with <varname>Type=dbus</varname> | |
289 | automatically acquire dependencies of type <varname>Requires=</varname> | |
290 | and <varname>After=</varname> on <filename>dbus.socket</filename>. See | |
291 | <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry> | |
c129bd5d LP |
292 | for details.</para> |
293 | </refsect1> | |
294 | ||
45f09f93 JL |
295 | <refsect1> |
296 | <title>Default Dependencies</title> | |
297 | ||
298 | <para>Default dependencies are similar to implicit dependencies, | |
299 | but can be turned on and off by setting | |
300 | <varname>DefaultDependencies=</varname> to <varname>yes</varname> | |
301 | (the default) and <varname>no</varname>, while implicit dependencies | |
302 | are always in effect. See section "Default Dependencies" in respective | |
303 | man pages for the effect of enabling | |
304 | <varname>DefaultDependencies=</varname> in each unit types.</para> | |
305 | ||
306 | <para>For example, target units will complement all configured | |
dcfaecc7 | 307 | dependencies of type <varname>Wants=</varname> or |
45f09f93 | 308 | <varname>Requires=</varname> with dependencies of type |
c85f1346 YW |
309 | <varname>After=</varname> unless <varname>DefaultDependencies=no</varname> |
310 | is set in the specified units. See | |
45f09f93 JL |
311 | <citerefentry><refentrytitle>systemd.target</refentrytitle><manvolnum>5</manvolnum></citerefentry> |
312 | for details. Note that this behavior can be turned off by setting | |
313 | <varname>DefaultDependencies=no</varname>.</para> | |
314 | </refsect1> | |
315 | ||
798d3a52 | 316 | <refsect1> |
f757855e | 317 | <title>Unit File Load Path</title> |
798d3a52 ZJS |
318 | |
319 | <para>Unit files are loaded from a set of paths determined during | |
320 | compilation, described in the two tables below. Unit files found | |
321 | in directories listed earlier override files with the same name in | |
322 | directories lower in the list.</para> | |
323 | ||
aa3e4400 EV |
324 | <para>When the variable <varname>$SYSTEMD_UNIT_PATH</varname> is set, |
325 | the contents of this variable overrides the unit load path. If | |
798d3a52 ZJS |
326 | <varname>$SYSTEMD_UNIT_PATH</varname> ends with an empty component |
327 | (<literal>:</literal>), the usual unit load path will be appended | |
328 | to the contents of the variable.</para> | |
329 | ||
330 | <table> | |
331 | <title> | |
332 | Load path when running in system mode (<option>--system</option>). | |
333 | </title> | |
334 | ||
335 | <tgroup cols='2'> | |
336 | <colspec colname='path' /> | |
337 | <colspec colname='expl' /> | |
338 | <thead> | |
339 | <row> | |
5a15caf4 ZJS |
340 | <entry>Path</entry> |
341 | <entry>Description</entry> | |
798d3a52 ZJS |
342 | </row> |
343 | </thead> | |
344 | <tbody> | |
345 | <row> | |
5a15caf4 ZJS |
346 | <entry><filename>/etc/systemd/system</filename></entry> |
347 | <entry>Local configuration</entry> | |
798d3a52 ZJS |
348 | </row> |
349 | <row> | |
5a15caf4 ZJS |
350 | <entry><filename>/run/systemd/system</filename></entry> |
351 | <entry>Runtime units</entry> | |
798d3a52 ZJS |
352 | </row> |
353 | <row> | |
5a15caf4 ZJS |
354 | <entry><filename>/usr/lib/systemd/system</filename></entry> |
355 | <entry>Units of installed packages</entry> | |
798d3a52 ZJS |
356 | </row> |
357 | </tbody> | |
358 | </tgroup> | |
359 | </table> | |
360 | ||
361 | <table> | |
362 | <title> | |
363 | Load path when running in user mode (<option>--user</option>). | |
364 | </title> | |
365 | ||
366 | <tgroup cols='2'> | |
367 | <colspec colname='path' /> | |
368 | <colspec colname='expl' /> | |
369 | <thead> | |
370 | <row> | |
5a15caf4 ZJS |
371 | <entry>Path</entry> |
372 | <entry>Description</entry> | |
798d3a52 ZJS |
373 | </row> |
374 | </thead> | |
375 | <tbody> | |
376 | <row> | |
5a15caf4 ZJS |
377 | <entry><filename>$XDG_CONFIG_HOME/systemd/user</filename></entry> |
378 | <entry>User configuration (only used when $XDG_CONFIG_HOME is set)</entry> | |
798d3a52 ZJS |
379 | </row> |
380 | <row> | |
5a15caf4 ZJS |
381 | <entry><filename>$HOME/.config/systemd/user</filename></entry> |
382 | <entry>User configuration (only used when $XDG_CONFIG_HOME is not set)</entry> | |
798d3a52 ZJS |
383 | </row> |
384 | <row> | |
5a15caf4 ZJS |
385 | <entry><filename>/etc/systemd/user</filename></entry> |
386 | <entry>Local configuration</entry> | |
798d3a52 ZJS |
387 | </row> |
388 | <row> | |
5a15caf4 ZJS |
389 | <entry><filename>$XDG_RUNTIME_DIR/systemd/user</filename></entry> |
390 | <entry>Runtime units (only used when $XDG_RUNTIME_DIR is set)</entry> | |
798d3a52 ZJS |
391 | </row> |
392 | <row> | |
5a15caf4 ZJS |
393 | <entry><filename>/run/systemd/user</filename></entry> |
394 | <entry>Runtime units</entry> | |
798d3a52 ZJS |
395 | </row> |
396 | <row> | |
5a15caf4 ZJS |
397 | <entry><filename>$XDG_DATA_HOME/systemd/user</filename></entry> |
398 | <entry>Units of packages that have been installed in the home directory (only used when $XDG_DATA_HOME is set)</entry> | |
798d3a52 ZJS |
399 | </row> |
400 | <row> | |
5a15caf4 ZJS |
401 | <entry><filename>$HOME/.local/share/systemd/user</filename></entry> |
402 | <entry>Units of packages that have been installed in the home directory (only used when $XDG_DATA_HOME is not set)</entry> | |
798d3a52 ZJS |
403 | </row> |
404 | <row> | |
5a15caf4 ZJS |
405 | <entry><filename>/usr/lib/systemd/user</filename></entry> |
406 | <entry>Units of packages that have been installed system-wide</entry> | |
798d3a52 ZJS |
407 | </row> |
408 | </tbody> | |
409 | </tgroup> | |
410 | </table> | |
411 | ||
412 | <para>Additional units might be loaded into systemd ("linked") | |
413 | from directories not on the unit load path. See the | |
414 | <command>link</command> command for | |
415 | <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>. | |
b1c1a519 ZC |
416 | Also, some units are dynamically created via a |
417 | <citerefentry><refentrytitle>systemd.generator</refentrytitle><manvolnum>7</manvolnum></citerefentry>. | |
798d3a52 ZJS |
418 | </para> |
419 | </refsect1> | |
420 | ||
5afe510c LP |
421 | <refsect1> |
422 | <title>Unit Garbage Collection</title> | |
423 | ||
424 | <para>The system and service manager loads a unit's configuration automatically when a unit is referenced for the | |
425 | first time. It will automatically unload the unit configuration and state again when the unit is not needed anymore | |
426 | ("garbage collection"). A unit may be referenced through a number of different mechanisms:</para> | |
427 | ||
428 | <orderedlist> | |
429 | <listitem><para>Another loaded unit references it with a dependency such as <varname>After=</varname>, | |
430 | <varname>Wants=</varname>, …</para></listitem> | |
431 | ||
432 | <listitem><para>The unit is currently starting, running, reloading or stopping.</para></listitem> | |
433 | ||
434 | <listitem><para>The unit is currently in the <constant>failed</constant> state. (But see below.)</para></listitem> | |
435 | ||
436 | <listitem><para>A job for the unit is pending.</para></listitem> | |
437 | ||
438 | <listitem><para>The unit is pinned by an active IPC client program.</para></listitem> | |
439 | ||
440 | <listitem><para>The unit is a special "perpetual" unit that is always active and loaded. Examples for perpetual | |
441 | units are the root mount unit <filename>-.mount</filename> or the scope unit <filename>init.scope</filename> that | |
442 | the service manager itself lives in.</para></listitem> | |
443 | ||
444 | <listitem><para>The unit has running processes associated with it.</para></listitem> | |
445 | </orderedlist> | |
446 | ||
447 | <para>The garbage collection logic may be altered with the <varname>CollectMode=</varname> option, which allows | |
448 | configuration whether automatic unloading of units that are in <constant>failed</constant> state is permissible, | |
449 | see below.</para> | |
450 | ||
451 | <para>Note that when a unit's configuration and state is unloaded, all execution results, such as exit codes, exit | |
452 | signals, resource consumption and other statistics are lost, except for what is stored in the log subsystem.</para> | |
453 | ||
454 | <para>Use <command>systemctl daemon-reload</command> or an equivalent command to reload unit configuration while | |
455 | the unit is already loaded. In this case all configuration settings are flushed out and replaced with the new | |
456 | configuration (which however might not be in effect immediately), however all runtime state is | |
457 | saved/restored.</para> | |
458 | </refsect1> | |
459 | ||
798d3a52 ZJS |
460 | <refsect1> |
461 | <title>[Unit] Section Options</title> | |
462 | ||
a8eaaee7 | 463 | <para>The unit file may include a [Unit] section, which carries |
798d3a52 ZJS |
464 | generic information about the unit that is not dependent on the |
465 | type of unit:</para> | |
466 | ||
467 | <variablelist class='unit-directives'> | |
468 | ||
469 | <varlistentry> | |
470 | <term><varname>Description=</varname></term> | |
471 | <listitem><para>A free-form string describing the unit. This | |
472 | is intended for use in UIs to show descriptive information | |
473 | along with the unit name. The description should contain a | |
474 | name that means something to the end user. <literal>Apache2 | |
475 | Web Server</literal> is a good example. Bad examples are | |
476 | <literal>high-performance light-weight HTTP server</literal> | |
477 | (too generic) or <literal>Apache2</literal> (too specific and | |
478 | meaningless for people who do not know | |
479 | Apache).</para></listitem> | |
480 | </varlistentry> | |
481 | ||
482 | <varlistentry> | |
483 | <term><varname>Documentation=</varname></term> | |
484 | <listitem><para>A space-separated list of URIs referencing | |
485 | documentation for this unit or its configuration. Accepted are | |
486 | only URIs of the types <literal>http://</literal>, | |
487 | <literal>https://</literal>, <literal>file:</literal>, | |
488 | <literal>info:</literal>, <literal>man:</literal>. For more | |
489 | information about the syntax of these URIs, see <citerefentry | |
490 | project='man-pages'><refentrytitle>uri</refentrytitle><manvolnum>7</manvolnum></citerefentry>. | |
491 | The URIs should be listed in order of relevance, starting with | |
492 | the most relevant. It is a good idea to first reference | |
493 | documentation that explains what the unit's purpose is, | |
494 | followed by how it is configured, followed by any other | |
495 | related documentation. This option may be specified more than | |
496 | once, in which case the specified list of URIs is merged. If | |
497 | the empty string is assigned to this option, the list is reset | |
498 | and all prior assignments will have no | |
499 | effect.</para></listitem> | |
500 | </varlistentry> | |
501 | ||
502 | <varlistentry> | |
503 | <term><varname>Requires=</varname></term> | |
504 | ||
62d3ca24 | 505 | <listitem><para>Configures requirement dependencies on other units. If this unit gets activated, the units |
a195dd8e | 506 | listed here will be activated as well. If one of the other units fails to activate, and an ordering dependency |
e79eabdb JL |
507 | <varname>After=</varname> on the failing unit is set, this unit will not be started. Besides, with or without |
508 | specifying <varname>After=</varname>, this unit will be deactivated if one of the other units get deactivated. | |
509 | This option may be specified more than once or multiple space-separated units may be | |
62d3ca24 LP |
510 | specified in one option in which case requirement dependencies for all listed names will be created. Note that |
511 | requirement dependencies do not influence the order in which services are started or stopped. This has to be | |
512 | configured independently with the <varname>After=</varname> or <varname>Before=</varname> options. If a unit | |
513 | <filename>foo.service</filename> requires a unit <filename>bar.service</filename> as configured with | |
514 | <varname>Requires=</varname> and no ordering is configured with <varname>After=</varname> or | |
515 | <varname>Before=</varname>, then both units will be started simultaneously and without any delay between them | |
516 | if <filename>foo.service</filename> is activated. Often, it is a better choice to use <varname>Wants=</varname> | |
517 | instead of <varname>Requires=</varname> in order to achieve a system that is more robust when dealing with | |
518 | failing services.</para> | |
519 | ||
520 | <para>Note that this dependency type does not imply that the other unit always has to be in active state when | |
521 | this unit is running. Specifically: failing condition checks (such as <varname>ConditionPathExists=</varname>, | |
6b5bb2f9 | 522 | <varname>ConditionPathIsSymbolicLink=</varname>, … — see below) do not cause the start job of a unit with a |
62d3ca24 LP |
523 | <varname>Requires=</varname> dependency on it to fail. Also, some unit types may deactivate on their own (for |
524 | example, a service process may decide to exit cleanly, or a device may be unplugged by the user), which is not | |
525 | propagated to units having a <varname>Requires=</varname> dependency. Use the <varname>BindsTo=</varname> | |
526 | dependency type together with <varname>After=</varname> to ensure that a unit may never be in active state | |
527 | without a specific other unit also in active state (see below).</para> | |
528 | ||
529 | <para>Note that dependencies of this type may also be configured outside of the unit configuration file by | |
530 | adding a symlink to a <filename>.requires/</filename> directory accompanying the unit file. For details, see | |
798d3a52 ZJS |
531 | above.</para></listitem> |
532 | </varlistentry> | |
533 | ||
798d3a52 ZJS |
534 | <varlistentry> |
535 | <term><varname>Requisite=</varname></term> | |
798d3a52 | 536 | |
f32b43bd | 537 | <listitem><para>Similar to <varname>Requires=</varname>. |
798d3a52 ZJS |
538 | However, if the units listed here are not started already, |
539 | they will not be started and the transaction will fail | |
b2920668 ZJS |
540 | immediately.</para> |
541 | ||
542 | <para>When <varname>Requisite=b.service</varname> is used on | |
543 | <filename>a.service</filename>, this dependency will show as | |
544 | <varname>RequisiteOf=a.service</varname> in property listing of | |
545 | <filename>b.service</filename>. <varname>RequisiteOf=</varname> | |
546 | dependency cannot be specified directly.</para> | |
547 | </listitem> | |
798d3a52 ZJS |
548 | </varlistentry> |
549 | ||
550 | <varlistentry> | |
551 | <term><varname>Wants=</varname></term> | |
552 | ||
553 | <listitem><para>A weaker version of | |
554 | <varname>Requires=</varname>. Units listed in this option will | |
555 | be started if the configuring unit is. However, if the listed | |
556 | units fail to start or cannot be added to the transaction, | |
557 | this has no impact on the validity of the transaction as a | |
558 | whole. This is the recommended way to hook start-up of one | |
559 | unit to the start-up of another unit.</para> | |
560 | ||
561 | <para>Note that dependencies of this type may also be | |
562 | configured outside of the unit configuration file by adding | |
563 | symlinks to a <filename>.wants/</filename> directory | |
564 | accompanying the unit file. For details, see | |
565 | above.</para></listitem> | |
566 | </varlistentry> | |
567 | ||
568 | <varlistentry> | |
569 | <term><varname>BindsTo=</varname></term> | |
570 | ||
62d3ca24 LP |
571 | <listitem><para>Configures requirement dependencies, very similar in style to |
572 | <varname>Requires=</varname>. However, this dependency type is stronger: in addition to the effect of | |
573 | <varname>Requires=</varname> it declares that if the unit bound to is stopped, this unit will be stopped | |
574 | too. This means a unit bound to another unit that suddenly enters inactive state will be stopped too. | |
575 | Units can suddenly, unexpectedly enter inactive state for different reasons: the main process of a service unit | |
576 | might terminate on its own choice, the backing device of a device unit might be unplugged or the mount point of | |
577 | a mount unit might be unmounted without involvement of the system and service manager.</para> | |
578 | ||
579 | <para>When used in conjunction with <varname>After=</varname> on the same unit the behaviour of | |
580 | <varname>BindsTo=</varname> is even stronger. In this case, the unit bound to strictly has to be in active | |
581 | state for this unit to also be in active state. This not only means a unit bound to another unit that suddenly | |
582 | enters inactive state, but also one that is bound to another unit that gets skipped due to a failed condition | |
583 | check (such as <varname>ConditionPathExists=</varname>, <varname>ConditionPathIsSymbolicLink=</varname>, … — | |
584 | see below) will be stopped, should it be running. Hence, in many cases it is best to combine | |
b2920668 ZJS |
585 | <varname>BindsTo=</varname> with <varname>After=</varname>.</para> |
586 | ||
587 | <para>When <varname>BindsTo=b.service</varname> is used on | |
588 | <filename>a.service</filename>, this dependency will show as | |
589 | <varname>BoundBy=a.service</varname> in property listing of | |
590 | <filename>b.service</filename>. <varname>BoundBy=</varname> | |
591 | dependency cannot be specified directly.</para> | |
592 | </listitem> | |
798d3a52 ZJS |
593 | </varlistentry> |
594 | ||
595 | <varlistentry> | |
596 | <term><varname>PartOf=</varname></term> | |
597 | ||
598 | <listitem><para>Configures dependencies similar to | |
599 | <varname>Requires=</varname>, but limited to stopping and | |
600 | restarting of units. When systemd stops or restarts the units | |
601 | listed here, the action is propagated to this unit. Note that | |
602 | this is a one-way dependency — changes to this unit do not | |
b2920668 ZJS |
603 | affect the listed units.</para> |
604 | ||
605 | <para>When <varname>PartOf=b.service</varname> is used on | |
606 | <filename>a.service</filename>, this dependency will show as | |
607 | <varname>ConsistsOf=a.service</varname> in property listing of | |
608 | <filename>b.service</filename>. <varname>ConsistsOf=</varname> | |
609 | dependency cannot be specified directly.</para> | |
610 | </listitem> | |
798d3a52 ZJS |
611 | </varlistentry> |
612 | ||
613 | <varlistentry> | |
614 | <term><varname>Conflicts=</varname></term> | |
615 | ||
616 | <listitem><para>A space-separated list of unit names. | |
617 | Configures negative requirement dependencies. If a unit has a | |
618 | <varname>Conflicts=</varname> setting on another unit, | |
619 | starting the former will stop the latter and vice versa. Note | |
620 | that this setting is independent of and orthogonal to the | |
621 | <varname>After=</varname> and <varname>Before=</varname> | |
622 | ordering dependencies.</para> | |
623 | ||
624 | <para>If a unit A that conflicts with a unit B is scheduled to | |
625 | be started at the same time as B, the transaction will either | |
626 | fail (in case both are required part of the transaction) or be | |
627 | modified to be fixed (in case one or both jobs are not a | |
628 | required part of the transaction). In the latter case, the job | |
629 | that is not the required will be removed, or in case both are | |
630 | not required, the unit that conflicts will be started and the | |
631 | unit that is conflicted is stopped.</para></listitem> | |
632 | </varlistentry> | |
633 | ||
634 | <varlistentry> | |
635 | <term><varname>Before=</varname></term> | |
636 | <term><varname>After=</varname></term> | |
637 | ||
2eb6ff5e LP |
638 | <listitem><para>These two settings expect a space-separated list of unit names. They configure ordering |
639 | dependencies between units. If a unit <filename>foo.service</filename> contains a setting | |
640 | <option>Before=bar.service</option> and both units are being started, <filename>bar.service</filename>'s | |
641 | start-up is delayed until <filename>foo.service</filename> has finished starting up. Note that this setting is | |
642 | independent of and orthogonal to the requirement dependencies as configured by <varname>Requires=</varname>, | |
643 | <varname>Wants=</varname> or <varname>BindsTo=</varname>. It is a common pattern to include a unit name in both | |
644 | the <varname>After=</varname> and <varname>Requires=</varname> options, in which case the unit listed will be | |
645 | started before the unit that is configured with these options. This option may be specified more than once, in | |
646 | which case ordering dependencies for all listed names are created. <varname>After=</varname> is the inverse of | |
647 | <varname>Before=</varname>, i.e. while <varname>After=</varname> ensures that the configured unit is started | |
648 | after the listed unit finished starting up, <varname>Before=</varname> ensures the opposite, that the | |
649 | configured unit is fully started up before the listed unit is started. Note that when two units with an | |
650 | ordering dependency between them are shut down, the inverse of the start-up order is applied. i.e. if a unit is | |
651 | configured with <varname>After=</varname> on another unit, the former is stopped before the latter if both are | |
652 | shut down. Given two units with any ordering dependency between them, if one unit is shut down and the other is | |
653 | started up, the shutdown is ordered before the start-up. It doesn't matter if the ordering dependency is | |
654 | <varname>After=</varname> or <varname>Before=</varname>, in this case. It also doesn't matter which of the two | |
655 | is shut down, as long as one is shut down and the other is started up. The shutdown is ordered before the | |
656 | start-up in all cases. If two units have no ordering dependencies between them, they are shut down or started | |
657 | up simultaneously, and no ordering takes place. It depends on the unit type when precisely a unit has finished | |
658 | starting up. Most importantly, for service units start-up is considered completed for the purpose of | |
659 | <varname>Before=</varname>/<varname>After=</varname> when all its configured start-up commands have been | |
660 | invoked and they either failed or reported start-up success.</para></listitem> | |
798d3a52 ZJS |
661 | </varlistentry> |
662 | ||
663 | <varlistentry> | |
664 | <term><varname>OnFailure=</varname></term> | |
665 | ||
666 | <listitem><para>A space-separated list of one or more units | |
667 | that are activated when this unit enters the | |
668 | <literal>failed</literal> state.</para></listitem> | |
669 | </varlistentry> | |
670 | ||
671 | <varlistentry> | |
672 | <term><varname>PropagatesReloadTo=</varname></term> | |
673 | <term><varname>ReloadPropagatedFrom=</varname></term> | |
674 | ||
675 | <listitem><para>A space-separated list of one or more units | |
676 | where reload requests on this unit will be propagated to, or | |
677 | reload requests on the other unit will be propagated to this | |
678 | unit, respectively. Issuing a reload request on a unit will | |
679 | automatically also enqueue a reload request on all units that | |
680 | the reload request shall be propagated to via these two | |
681 | settings.</para></listitem> | |
682 | </varlistentry> | |
683 | ||
684 | <varlistentry> | |
685 | <term><varname>JoinsNamespaceOf=</varname></term> | |
686 | ||
687 | <listitem><para>For units that start processes (such as | |
688 | service units), lists one or more other units whose network | |
689 | and/or temporary file namespace to join. This only applies to | |
690 | unit types which support the | |
691 | <varname>PrivateNetwork=</varname> and | |
692 | <varname>PrivateTmp=</varname> directives (see | |
693 | <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry> | |
694 | for details). If a unit that has this setting set is started, | |
695 | its processes will see the same <filename>/tmp</filename>, | |
80f524a4 | 696 | <filename>/var/tmp</filename> and network namespace as one |
798d3a52 ZJS |
697 | listed unit that is started. If multiple listed units are |
698 | already started, it is not defined which namespace is joined. | |
699 | Note that this setting only has an effect if | |
700 | <varname>PrivateNetwork=</varname> and/or | |
701 | <varname>PrivateTmp=</varname> is enabled for both the unit | |
702 | that joins the namespace and the unit whose namespace is | |
703 | joined.</para></listitem> | |
704 | </varlistentry> | |
705 | ||
706 | <varlistentry> | |
707 | <term><varname>RequiresMountsFor=</varname></term> | |
708 | ||
709 | <listitem><para>Takes a space-separated list of absolute | |
710 | paths. Automatically adds dependencies of type | |
711 | <varname>Requires=</varname> and <varname>After=</varname> for | |
712 | all mount units required to access the specified path.</para> | |
713 | ||
714 | <para>Mount points marked with <option>noauto</option> are not | |
88e328fd ZJS |
715 | mounted automatically through <filename>local-fs.target</filename>, |
716 | but are still honored for the purposes of this option, i.e. they | |
717 | will be pulled in by this unit.</para></listitem> | |
798d3a52 ZJS |
718 | </varlistentry> |
719 | ||
720 | <varlistentry> | |
721 | <term><varname>OnFailureJobMode=</varname></term> | |
722 | ||
723 | <listitem><para>Takes a value of | |
724 | <literal>fail</literal>, | |
725 | <literal>replace</literal>, | |
726 | <literal>replace-irreversibly</literal>, | |
727 | <literal>isolate</literal>, | |
728 | <literal>flush</literal>, | |
729 | <literal>ignore-dependencies</literal> or | |
730 | <literal>ignore-requirements</literal>. Defaults to | |
731 | <literal>replace</literal>. Specifies how the units listed in | |
732 | <varname>OnFailure=</varname> will be enqueued. See | |
733 | <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>'s | |
734 | <option>--job-mode=</option> option for details on the | |
735 | possible values. If this is set to <literal>isolate</literal>, | |
736 | only a single unit may be listed in | |
737 | <varname>OnFailure=</varname>..</para></listitem> | |
738 | </varlistentry> | |
739 | ||
740 | <varlistentry> | |
741 | <term><varname>IgnoreOnIsolate=</varname></term> | |
742 | ||
26adf774 ZJS |
743 | <listitem><para>Takes a boolean argument. If <option>true</option>, this unit |
744 | will not be stopped when isolating another unit. Defaults to | |
745 | <option>false</option> for service, target, socket, busname, timer, and path | |
746 | units, and <option>true</option> for slice, scope, device, swap, mount, and | |
747 | automount units.</para></listitem> | |
798d3a52 ZJS |
748 | </varlistentry> |
749 | ||
798d3a52 ZJS |
750 | <varlistentry> |
751 | <term><varname>StopWhenUnneeded=</varname></term> | |
752 | ||
753 | <listitem><para>Takes a boolean argument. If | |
754 | <option>true</option>, this unit will be stopped when it is no | |
b938cb90 | 755 | longer used. Note that, in order to minimize the work to be |
798d3a52 ZJS |
756 | executed, systemd will not stop units by default unless they |
757 | are conflicting with other units, or the user explicitly | |
758 | requested their shut down. If this option is set, a unit will | |
759 | be automatically cleaned up if no other active unit requires | |
760 | it. Defaults to <option>false</option>.</para></listitem> | |
761 | </varlistentry> | |
762 | ||
763 | <varlistentry> | |
764 | <term><varname>RefuseManualStart=</varname></term> | |
765 | <term><varname>RefuseManualStop=</varname></term> | |
766 | ||
767 | <listitem><para>Takes a boolean argument. If | |
768 | <option>true</option>, this unit can only be activated or | |
769 | deactivated indirectly. In this case, explicit start-up or | |
770 | termination requested by the user is denied, however if it is | |
771 | started or stopped as a dependency of another unit, start-up | |
772 | or termination will succeed. This is mostly a safety feature | |
773 | to ensure that the user does not accidentally activate units | |
774 | that are not intended to be activated explicitly, and not | |
775 | accidentally deactivate units that are not intended to be | |
776 | deactivated. These options default to | |
777 | <option>false</option>.</para></listitem> | |
778 | </varlistentry> | |
779 | ||
780 | <varlistentry> | |
781 | <term><varname>AllowIsolate=</varname></term> | |
782 | ||
783 | <listitem><para>Takes a boolean argument. If | |
784 | <option>true</option>, this unit may be used with the | |
785 | <command>systemctl isolate</command> command. Otherwise, this | |
786 | will be refused. It probably is a good idea to leave this | |
787 | disabled except for target units that shall be used similar to | |
788 | runlevels in SysV init systems, just as a precaution to avoid | |
789 | unusable system states. This option defaults to | |
790 | <option>false</option>.</para></listitem> | |
791 | </varlistentry> | |
792 | ||
793 | <varlistentry> | |
794 | <term><varname>DefaultDependencies=</varname></term> | |
795 | ||
796 | <listitem><para>Takes a boolean argument. If | |
797 | <option>true</option>, (the default), a few default | |
798 | dependencies will implicitly be created for the unit. The | |
799 | actual dependencies created depend on the unit type. For | |
800 | example, for service units, these dependencies ensure that the | |
801 | service is started only after basic system initialization is | |
802 | completed and is properly terminated on system shutdown. See | |
803 | the respective man pages for details. Generally, only services | |
804 | involved with early boot or late shutdown should set this | |
805 | option to <option>false</option>. It is highly recommended to | |
806 | leave this option enabled for the majority of common units. If | |
807 | set to <option>false</option>, this option does not disable | |
808 | all implicit dependencies, just non-essential | |
809 | ones.</para></listitem> | |
810 | </varlistentry> | |
811 | ||
5afe510c LP |
812 | <varlistentry> |
813 | <term><varname>CollectMode=</varname></term> | |
814 | ||
815 | <listitem><para>Tweaks the "garbage collection" algorithm for this unit. Takes one of <option>inactive</option> | |
816 | or <option>inactive-or-failed</option>. If set to <option>inactive</option> the unit will be unloaded if it is | |
817 | in the <constant>inactive</constant> state and is not referenced by clients, jobs or other units — however it | |
818 | is not unloaded if it is in the <constant>failed</constant> state. In <option>failed</option> mode, failed | |
819 | units are not unloaded until the user invoked <command>systemctl reset-failed</command> on them to reset the | |
820 | <constant>failed</constant> state, or an equivalent command. This behaviour is altered if this option is set to | |
821 | <option>inactive-or-failed</option>: in this case the unit is unloaded even if the unit is in a | |
822 | <constant>failed</constant> state, and thus an explicitly resetting of the <constant>failed</constant> state is | |
823 | not necessary. Note that if this mode is used unit results (such as exit codes, exit signals, consumed | |
824 | resources, …) are flushed out immediately after the unit completed, except for what is stored in the logging | |
825 | subsystem. Defaults to <option>inactive</option>.</para> | |
826 | </listitem> | |
827 | </varlistentry> | |
828 | ||
798d3a52 ZJS |
829 | <varlistentry> |
830 | <term><varname>JobTimeoutSec=</varname></term> | |
a2df3ea4 | 831 | <term><varname>JobRunningTimeoutSec=</varname></term> |
798d3a52 ZJS |
832 | <term><varname>JobTimeoutAction=</varname></term> |
833 | <term><varname>JobTimeoutRebootArgument=</varname></term> | |
834 | ||
a2df3ea4 MK |
835 | <listitem><para>When a job for this unit is queued, a time-out <varname>JobTimeoutSec=</varname> may be |
836 | configured. Similarly, <varname>JobRunningTimeoutSec=</varname> starts counting when the queued job is actually | |
837 | started. If either time limit is reached, the job will be cancelled, the unit however will not change state or | |
838 | even enter the <literal>failed</literal> mode. This value defaults to <literal>infinity</literal> (job timeouts | |
839 | disabled), except for device units (<varname>JobRunningTimeoutSec=</varname> defaults to | |
840 | <varname>DefaultTimeoutStartSec=</varname>). NB: this timeout is independent from any unit-specific timeout | |
841 | (for example, the timeout set with <varname>TimeoutStartSec=</varname> in service units) as the job timeout has | |
842 | no effect on the unit itself, only on the job that might be pending for it. Or in other words: unit-specific | |
843 | timeouts are useful to abort unit state changes, and revert them. The job timeout set with this option however | |
844 | is useful to abort only the job waiting for the unit state to change.</para> | |
798d3a52 | 845 | |
0aabe747 AJ |
846 | <para><varname>JobTimeoutAction=</varname> optionally configures an additional action to take when the time-out |
847 | is hit. It takes the same values as <varname>StartLimitAction=</varname>. Defaults to <option>none</option>. | |
848 | <varname>JobTimeoutRebootArgument=</varname> configures an optional reboot string to pass to the | |
798d3a52 ZJS |
849 | <citerefentry><refentrytitle>reboot</refentrytitle><manvolnum>2</manvolnum></citerefentry> |
850 | system call.</para></listitem> | |
851 | </varlistentry> | |
852 | ||
6bf0f408 | 853 | <varlistentry> |
fc5ffacd ZJS |
854 | <term><varname>StartLimitIntervalSec=<replaceable>interval</replaceable></varname></term> |
855 | <term><varname>StartLimitBurst=<replaceable>burst</replaceable></varname></term> | |
6bf0f408 | 856 | |
fc5ffacd | 857 | <listitem><para>Configure unit start rate limiting. Units which are started more than |
b94f4313 LP |
858 | <replaceable>burst</replaceable> times within an <replaceable>interval</replaceable> time interval are not |
859 | permitted to start any more. Use <varname>StartLimitIntervalSec=</varname> to configure the checking interval | |
860 | (defaults to <varname>DefaultStartLimitIntervalSec=</varname> in manager configuration file, set it to 0 to | |
861 | disable any kind of rate limiting). Use <varname>StartLimitBurst=</varname> to configure how many starts per | |
862 | interval are allowed (defaults to <varname>DefaultStartLimitBurst=</varname> in manager configuration | |
863 | file). These configuration options are particularly useful in conjunction with the service setting | |
864 | <varname>Restart=</varname> (see | |
6bf0f408 LP |
865 | <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>); however, |
866 | they apply to all kinds of starts (including manual), not just those triggered by the | |
867 | <varname>Restart=</varname> logic. Note that units which are configured for <varname>Restart=</varname> and | |
868 | which reach the start limit are not attempted to be restarted anymore; however, they may still be restarted | |
b94f4313 LP |
869 | manually at a later point, after the <replaceable>interval</replaceable> has passed. From this point on, the |
870 | restart logic is activated again. Note that <command>systemctl reset-failed</command> will cause the restart | |
871 | rate counter for a service to be flushed, which is useful if the administrator wants to manually start a unit | |
872 | and the start limit interferes with that. Note that this rate-limiting is enforced after any unit condition | |
873 | checks are executed, and hence unit activations with failing conditions do not count towards this rate | |
874 | limit. This setting does not apply to slice, target, device, and scope units, since they are unit types whose | |
875 | activation may either never fail, or may succeed only a single time.</para> | |
876 | ||
877 | <para>When a unit is unloaded due to the garbage collection logic (see above) its rate limit counters are | |
878 | flushed out too. This means that configuring start rate limiting for a unit that is not referenced continously | |
879 | has no effect.</para></listitem> | |
6bf0f408 LP |
880 | </varlistentry> |
881 | ||
882 | <varlistentry> | |
883 | <term><varname>StartLimitAction=</varname></term> | |
884 | ||
885 | <listitem><para>Configure the action to take if the rate limit configured with | |
f0367da7 | 886 | <varname>StartLimitIntervalSec=</varname> and <varname>StartLimitBurst=</varname> is hit. Takes one of |
6bf0f408 LP |
887 | <option>none</option>, <option>reboot</option>, <option>reboot-force</option>, |
888 | <option>reboot-immediate</option>, <option>poweroff</option>, <option>poweroff-force</option> or | |
889 | <option>poweroff-immediate</option>. If <option>none</option> is set, hitting the rate limit will trigger no | |
890 | action besides that the start will not be permitted. <option>reboot</option> causes a reboot following the | |
891 | normal shutdown procedure (i.e. equivalent to <command>systemctl reboot</command>). | |
892 | <option>reboot-force</option> causes a forced reboot which will terminate all processes forcibly but should | |
893 | cause no dirty file systems on reboot (i.e. equivalent to <command>systemctl reboot -f</command>) and | |
894 | <option>reboot-immediate</option> causes immediate execution of the | |
895 | <citerefentry><refentrytitle>reboot</refentrytitle><manvolnum>2</manvolnum></citerefentry> system call, which | |
896 | might result in data loss. Similarly, <option>poweroff</option>, <option>poweroff-force</option>, | |
897 | <option>poweroff-immediate</option> have the effect of powering down the system with similar | |
898 | semantics. Defaults to <option>none</option>.</para></listitem> | |
899 | </varlistentry> | |
900 | ||
53c35a76 LP |
901 | <varlistentry> |
902 | <term><varname>FailureAction=</varname></term> | |
e7dfbb4e LP |
903 | <term><varname>SuccessAction=</varname></term> |
904 | <listitem><para>Configure the action to take when the unit stops and enters a failed state or inactive | |
905 | state. Takes the same values as the setting <varname>StartLimitAction=</varname> setting and executes the same | |
906 | actions (see | |
907 | <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>). Both options | |
908 | default to <option>none</option>.</para></listitem> | |
53c35a76 LP |
909 | </varlistentry> |
910 | ||
6bf0f408 LP |
911 | <varlistentry> |
912 | <term><varname>RebootArgument=</varname></term> | |
913 | <listitem><para>Configure the optional argument for the | |
914 | <citerefentry><refentrytitle>reboot</refentrytitle><manvolnum>2</manvolnum></citerefentry> system call if | |
53c35a76 | 915 | <varname>StartLimitAction=</varname> or <varname>FailureAction=</varname> is a reboot action. This |
6bf0f408 LP |
916 | works just like the optional argument to <command>systemctl reboot</command> command.</para></listitem> |
917 | </varlistentry> | |
918 | ||
798d3a52 ZJS |
919 | <varlistentry> |
920 | <term><varname>ConditionArchitecture=</varname></term> | |
921 | <term><varname>ConditionVirtualization=</varname></term> | |
922 | <term><varname>ConditionHost=</varname></term> | |
923 | <term><varname>ConditionKernelCommandLine=</varname></term> | |
924 | <term><varname>ConditionSecurity=</varname></term> | |
925 | <term><varname>ConditionCapability=</varname></term> | |
926 | <term><varname>ConditionACPower=</varname></term> | |
927 | <term><varname>ConditionNeedsUpdate=</varname></term> | |
928 | <term><varname>ConditionFirstBoot=</varname></term> | |
929 | <term><varname>ConditionPathExists=</varname></term> | |
930 | <term><varname>ConditionPathExistsGlob=</varname></term> | |
931 | <term><varname>ConditionPathIsDirectory=</varname></term> | |
932 | <term><varname>ConditionPathIsSymbolicLink=</varname></term> | |
933 | <term><varname>ConditionPathIsMountPoint=</varname></term> | |
934 | <term><varname>ConditionPathIsReadWrite=</varname></term> | |
935 | <term><varname>ConditionDirectoryNotEmpty=</varname></term> | |
936 | <term><varname>ConditionFileNotEmpty=</varname></term> | |
937 | <term><varname>ConditionFileIsExecutable=</varname></term> | |
c465a29f FS |
938 | <term><varname>ConditionUser=</varname></term> |
939 | <term><varname>ConditionGroup=</varname></term> | |
798d3a52 | 940 | |
7ca41557 | 941 | <!-- We do not document ConditionNull= |
b938cb90 | 942 | here, as it is not particularly |
798d3a52 ZJS |
943 | useful and probably just |
944 | confusing. --> | |
945 | ||
41448597 LP |
946 | <listitem><para>Before starting a unit, verify that the specified condition is true. If it is not true, the |
947 | starting of the unit will be (mostly silently) skipped, however all ordering dependencies of it are still | |
948 | respected. A failing condition will not result in the unit being moved into a failure state. The condition is | |
949 | checked at the time the queued start job is to be executed. Use condition expressions in order to silently skip | |
950 | units that do not apply to the local running system, for example because the kernel or runtime environment | |
951 | doesn't require its functionality. Use the various <varname>AssertArchitecture=</varname>, | |
952 | <varname>AssertVirtualization=</varname>, … options for a similar mechanism that puts the unit in a failure | |
953 | state and logs about the failed check (see below).</para> | |
798d3a52 ZJS |
954 | |
955 | <para><varname>ConditionArchitecture=</varname> may be used to | |
956 | check whether the system is running on a specific | |
957 | architecture. Takes one of | |
958 | <varname>x86</varname>, | |
959 | <varname>x86-64</varname>, | |
960 | <varname>ppc</varname>, | |
961 | <varname>ppc-le</varname>, | |
962 | <varname>ppc64</varname>, | |
963 | <varname>ppc64-le</varname>, | |
964 | <varname>ia64</varname>, | |
965 | <varname>parisc</varname>, | |
966 | <varname>parisc64</varname>, | |
967 | <varname>s390</varname>, | |
968 | <varname>s390x</varname>, | |
969 | <varname>sparc</varname>, | |
970 | <varname>sparc64</varname>, | |
971 | <varname>mips</varname>, | |
972 | <varname>mips-le</varname>, | |
973 | <varname>mips64</varname>, | |
974 | <varname>mips64-le</varname>, | |
975 | <varname>alpha</varname>, | |
976 | <varname>arm</varname>, | |
977 | <varname>arm-be</varname>, | |
978 | <varname>arm64</varname>, | |
979 | <varname>arm64-be</varname>, | |
980 | <varname>sh</varname>, | |
981 | <varname>sh64</varname>, | |
215a2db4 | 982 | <varname>m68k</varname>, |
798d3a52 | 983 | <varname>tilegx</varname>, |
27b09f1f AB |
984 | <varname>cris</varname>, |
985 | <varname>arc</varname>, | |
986 | <varname>arc-be</varname> to test | |
798d3a52 ZJS |
987 | against a specific architecture. The architecture is |
988 | determined from the information returned by | |
3ba3a79d | 989 | <citerefentry project='man-pages'><refentrytitle>uname</refentrytitle><manvolnum>2</manvolnum></citerefentry> |
798d3a52 ZJS |
990 | and is thus subject to |
991 | <citerefentry><refentrytitle>personality</refentrytitle><manvolnum>2</manvolnum></citerefentry>. | |
992 | Note that a <varname>Personality=</varname> setting in the | |
993 | same unit file has no effect on this condition. A special | |
994 | architecture name <varname>native</varname> is mapped to the | |
995 | architecture the system manager itself is compiled for. The | |
996 | test may be negated by prepending an exclamation mark.</para> | |
997 | ||
998 | <para><varname>ConditionVirtualization=</varname> may be used | |
999 | to check whether the system is executed in a virtualized | |
1000 | environment and optionally test whether it is a specific | |
1001 | implementation. Takes either boolean value to check if being | |
1002 | executed in any virtualized environment, or one of | |
1003 | <varname>vm</varname> and | |
1004 | <varname>container</varname> to test against a generic type of | |
1005 | virtualization solution, or one of | |
1006 | <varname>qemu</varname>, | |
1007 | <varname>kvm</varname>, | |
1008 | <varname>zvm</varname>, | |
1009 | <varname>vmware</varname>, | |
1010 | <varname>microsoft</varname>, | |
1011 | <varname>oracle</varname>, | |
1012 | <varname>xen</varname>, | |
1013 | <varname>bochs</varname>, | |
1014 | <varname>uml</varname>, | |
1015 | <varname>openvz</varname>, | |
1016 | <varname>lxc</varname>, | |
1017 | <varname>lxc-libvirt</varname>, | |
1018 | <varname>systemd-nspawn</varname>, | |
9fb16425 ILG |
1019 | <varname>docker</varname>, |
1020 | <varname>rkt</varname> to test | |
299a34c1 ZJS |
1021 | against a specific implementation, or |
1022 | <varname>private-users</varname> to check whether we are running in a user namespace. See | |
798d3a52 ZJS |
1023 | <citerefentry><refentrytitle>systemd-detect-virt</refentrytitle><manvolnum>1</manvolnum></citerefentry> |
1024 | for a full list of known virtualization technologies and their | |
1025 | identifiers. If multiple virtualization technologies are | |
1026 | nested, only the innermost is considered. The test may be | |
1027 | negated by prepending an exclamation mark.</para> | |
1028 | ||
1029 | <para><varname>ConditionHost=</varname> may be used to match | |
1030 | against the hostname or machine ID of the host. This either | |
1031 | takes a hostname string (optionally with shell style globs) | |
1032 | which is tested against the locally set hostname as returned | |
1033 | by | |
1034 | <citerefentry><refentrytitle>gethostname</refentrytitle><manvolnum>2</manvolnum></citerefentry>, | |
1035 | or a machine ID formatted as string (see | |
1036 | <citerefentry><refentrytitle>machine-id</refentrytitle><manvolnum>5</manvolnum></citerefentry>). | |
1037 | The test may be negated by prepending an exclamation | |
1038 | mark.</para> | |
1039 | ||
1040 | <para><varname>ConditionKernelCommandLine=</varname> may be | |
1041 | used to check whether a specific kernel command line option is | |
1042 | set (or if prefixed with the exclamation mark unset). The | |
1043 | argument must either be a single word, or an assignment (i.e. | |
1044 | two words, separated <literal>=</literal>). In the former case | |
1045 | the kernel command line is searched for the word appearing as | |
1046 | is, or as left hand side of an assignment. In the latter case, | |
1047 | the exact assignment is looked for with right and left hand | |
1048 | side matching.</para> | |
1049 | ||
1050 | <para><varname>ConditionSecurity=</varname> may be used to | |
1051 | check whether the given security module is enabled on the | |
b8e1d4d1 | 1052 | system. Currently, the recognized values are |
798d3a52 ZJS |
1053 | <varname>selinux</varname>, |
1054 | <varname>apparmor</varname>, | |
ed440f6b | 1055 | <varname>tomoyo</varname>, |
798d3a52 ZJS |
1056 | <varname>ima</varname>, |
1057 | <varname>smack</varname> and | |
1058 | <varname>audit</varname>. The test may be negated by | |
1059 | prepending an exclamation mark.</para> | |
1060 | ||
1061 | <para><varname>ConditionCapability=</varname> may be used to | |
1062 | check whether the given capability exists in the capability | |
1063 | bounding set of the service manager (i.e. this does not check | |
1064 | whether capability is actually available in the permitted or | |
1065 | effective sets, see | |
1066 | <citerefentry project='man-pages'><refentrytitle>capabilities</refentrytitle><manvolnum>7</manvolnum></citerefentry> | |
1067 | for details). Pass a capability name such as | |
1068 | <literal>CAP_MKNOD</literal>, possibly prefixed with an | |
1069 | exclamation mark to negate the check.</para> | |
1070 | ||
1071 | <para><varname>ConditionACPower=</varname> may be used to | |
1072 | check whether the system has AC power, or is exclusively | |
1073 | battery powered at the time of activation of the unit. This | |
1074 | takes a boolean argument. If set to <varname>true</varname>, | |
1075 | the condition will hold only if at least one AC connector of | |
1076 | the system is connected to a power source, or if no AC | |
1077 | connectors are known. Conversely, if set to | |
1078 | <varname>false</varname>, the condition will hold only if | |
1079 | there is at least one AC connector known and all AC connectors | |
1080 | are disconnected from a power source.</para> | |
1081 | ||
1082 | <para><varname>ConditionNeedsUpdate=</varname> takes one of | |
1083 | <filename>/var</filename> or <filename>/etc</filename> as | |
1084 | argument, possibly prefixed with a <literal>!</literal> (for | |
1085 | inverting the condition). This condition may be used to | |
1086 | conditionalize units on whether the specified directory | |
1087 | requires an update because <filename>/usr</filename>'s | |
1088 | modification time is newer than the stamp file | |
1089 | <filename>.updated</filename> in the specified directory. This | |
1090 | is useful to implement offline updates of the vendor operating | |
1091 | system resources in <filename>/usr</filename> that require | |
1092 | updating of <filename>/etc</filename> or | |
1093 | <filename>/var</filename> on the next following boot. Units | |
1094 | making use of this condition should order themselves before | |
1095 | <citerefentry><refentrytitle>systemd-update-done.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>, | |
7f3fdb7f | 1096 | to make sure they run before the stamp file's modification |
798d3a52 ZJS |
1097 | time gets reset indicating a completed update.</para> |
1098 | ||
23254af1 LP |
1099 | <para><varname>ConditionFirstBoot=</varname> takes a boolean argument. This condition may be used to |
1100 | conditionalize units on whether the system is booting up with an unpopulated <filename>/etc</filename> | |
1101 | directory (specifically: an <filename>/etc</filename> with no <filename>/etc/machine-id</filename>). This may | |
1102 | be used to populate <filename>/etc</filename> on the first boot after factory reset, or when a new system | |
1103 | instance boots up for the first time.</para> | |
798d3a52 ZJS |
1104 | |
1105 | <para>With <varname>ConditionPathExists=</varname> a file | |
1106 | existence condition is checked before a unit is started. If | |
1107 | the specified absolute path name does not exist, the condition | |
1108 | will fail. If the absolute path name passed to | |
1109 | <varname>ConditionPathExists=</varname> is prefixed with an | |
1110 | exclamation mark (<literal>!</literal>), the test is negated, | |
1111 | and the unit is only started if the path does not | |
1112 | exist.</para> | |
1113 | ||
1114 | <para><varname>ConditionPathExistsGlob=</varname> is similar | |
1115 | to <varname>ConditionPathExists=</varname>, but checks for the | |
1116 | existence of at least one file or directory matching the | |
1117 | specified globbing pattern.</para> | |
1118 | ||
1119 | <para><varname>ConditionPathIsDirectory=</varname> is similar | |
1120 | to <varname>ConditionPathExists=</varname> but verifies | |
1121 | whether a certain path exists and is a directory.</para> | |
1122 | ||
1123 | <para><varname>ConditionPathIsSymbolicLink=</varname> is | |
1124 | similar to <varname>ConditionPathExists=</varname> but | |
1125 | verifies whether a certain path exists and is a symbolic | |
1126 | link.</para> | |
1127 | ||
1128 | <para><varname>ConditionPathIsMountPoint=</varname> is similar | |
1129 | to <varname>ConditionPathExists=</varname> but verifies | |
1130 | whether a certain path exists and is a mount point.</para> | |
1131 | ||
1132 | <para><varname>ConditionPathIsReadWrite=</varname> is similar | |
1133 | to <varname>ConditionPathExists=</varname> but verifies | |
1134 | whether the underlying file system is readable and writable | |
1135 | (i.e. not mounted read-only).</para> | |
1136 | ||
1137 | <para><varname>ConditionDirectoryNotEmpty=</varname> is | |
1138 | similar to <varname>ConditionPathExists=</varname> but | |
1139 | verifies whether a certain path exists and is a non-empty | |
1140 | directory.</para> | |
1141 | ||
1142 | <para><varname>ConditionFileNotEmpty=</varname> is similar to | |
1143 | <varname>ConditionPathExists=</varname> but verifies whether a | |
1144 | certain path exists and refers to a regular file with a | |
1145 | non-zero size.</para> | |
1146 | ||
1147 | <para><varname>ConditionFileIsExecutable=</varname> is similar | |
1148 | to <varname>ConditionPathExists=</varname> but verifies | |
1149 | whether a certain path exists, is a regular file and marked | |
1150 | executable.</para> | |
1151 | ||
c465a29f | 1152 | <para><varname>ConditionUser=</varname> takes a numeric |
534bab66 FS |
1153 | <literal>UID</literal>, a UNIX user name, or the special value |
1154 | <literal>@system</literal>. This condition may be used to check | |
1155 | whether the service manager is running as the given user. The | |
1156 | special value <literal>@system</literal> can be used to check | |
1157 | if the user id is within the system user range. This option is not | |
c465a29f FS |
1158 | useful for system services, as the system manager exclusively |
1159 | runs as the root user, and thus the test result is constant.</para> | |
1160 | ||
1161 | <para><varname>ConditionGroup=</varname> is similar | |
1162 | to <varname>ConditionUser=</varname> but verifies that the | |
1163 | service manager's real or effective group, or any of its | |
534bab66 FS |
1164 | auxiliary groups match the specified group or GID. This setting |
1165 | does not have a special value <literal>@system</literal>.</para> | |
c465a29f | 1166 | |
798d3a52 ZJS |
1167 | <para>If multiple conditions are specified, the unit will be |
1168 | executed if all of them apply (i.e. a logical AND is applied). | |
1169 | Condition checks can be prefixed with a pipe symbol (|) in | |
1170 | which case a condition becomes a triggering condition. If at | |
1171 | least one triggering condition is defined for a unit, then the | |
1172 | unit will be executed if at least one of the triggering | |
1173 | conditions apply and all of the non-triggering conditions. If | |
1174 | you prefix an argument with the pipe symbol and an exclamation | |
1175 | mark, the pipe symbol must be passed first, the exclamation | |
1176 | second. Except for | |
1177 | <varname>ConditionPathIsSymbolicLink=</varname>, all path | |
1178 | checks follow symlinks. If any of these options is assigned | |
1179 | the empty string, the list of conditions is reset completely, | |
1180 | all previous condition settings (of any kind) will have no | |
1181 | effect.</para></listitem> | |
1182 | </varlistentry> | |
1183 | ||
1184 | <varlistentry> | |
1185 | <term><varname>AssertArchitecture=</varname></term> | |
1186 | <term><varname>AssertVirtualization=</varname></term> | |
1187 | <term><varname>AssertHost=</varname></term> | |
1188 | <term><varname>AssertKernelCommandLine=</varname></term> | |
1189 | <term><varname>AssertSecurity=</varname></term> | |
1190 | <term><varname>AssertCapability=</varname></term> | |
1191 | <term><varname>AssertACPower=</varname></term> | |
1192 | <term><varname>AssertNeedsUpdate=</varname></term> | |
1193 | <term><varname>AssertFirstBoot=</varname></term> | |
1194 | <term><varname>AssertPathExists=</varname></term> | |
1195 | <term><varname>AssertPathExistsGlob=</varname></term> | |
1196 | <term><varname>AssertPathIsDirectory=</varname></term> | |
1197 | <term><varname>AssertPathIsSymbolicLink=</varname></term> | |
1198 | <term><varname>AssertPathIsMountPoint=</varname></term> | |
1199 | <term><varname>AssertPathIsReadWrite=</varname></term> | |
1200 | <term><varname>AssertDirectoryNotEmpty=</varname></term> | |
1201 | <term><varname>AssertFileNotEmpty=</varname></term> | |
1202 | <term><varname>AssertFileIsExecutable=</varname></term> | |
c465a29f FS |
1203 | <term><varname>AssertUser=</varname></term> |
1204 | <term><varname>AssertGroup=</varname></term> | |
798d3a52 | 1205 | |
41448597 LP |
1206 | <listitem><para>Similar to the <varname>ConditionArchitecture=</varname>, |
1207 | <varname>ConditionVirtualization=</varname>, …, condition settings described above, these settings add | |
1208 | assertion checks to the start-up of the unit. However, unlike the conditions settings, any assertion setting | |
da25e029 ZJS |
1209 | that is not met results in failure of the start job (which means this is logged loudly). Use assertion |
1210 | expressions for units that cannot operate when specific requirements are not met, and when this is something | |
1211 | the administrator or user should look into.</para></listitem> | |
798d3a52 ZJS |
1212 | </varlistentry> |
1213 | ||
1214 | <varlistentry> | |
1215 | <term><varname>SourcePath=</varname></term> | |
1216 | <listitem><para>A path to a configuration file this unit has | |
1217 | been generated from. This is primarily useful for | |
1218 | implementation of generator tools that convert configuration | |
1219 | from an external configuration file format into native unit | |
1220 | files. This functionality should not be used in normal | |
1221 | units.</para></listitem> | |
1222 | </varlistentry> | |
1223 | </variablelist> | |
2bf92506 ZJS |
1224 | </refsect1> |
1225 | ||
1226 | <refsect1> | |
1227 | <title>Mapping of unit properties to their inverses</title> | |
1228 | ||
1229 | <para>Unit settings that create a relationship with a second unit usually show up | |
1230 | in properties of both units, for example in <command>systemctl show</command> | |
1231 | output. In some cases the name of the property is the same as the name of the | |
1232 | configuration setting, but not always. This table lists the pairs of properties | |
1233 | that are shown on two units which are connected through some dependency, and shows | |
1234 | which property on "source" unit corresponds to which property on the "target" unit. | |
1235 | </para> | |
1236 | ||
1237 | <table> | |
1238 | <title> | |
1239 | "Forward" and "reverse" unit properties | |
1240 | </title> | |
1241 | ||
1242 | <tgroup cols='2'> | |
1243 | <colspec colname='forward' /> | |
1244 | <colspec colname='reverse' /> | |
1245 | <colspec colname='notes' /> | |
1246 | <thead> | |
1247 | <row> | |
1248 | <entry>"Forward" property</entry> | |
1249 | <entry>"Reverse" property</entry> | |
1250 | <entry>Where used</entry> | |
1251 | </row> | |
1252 | </thead> | |
1253 | <tbody> | |
1254 | <row> | |
1255 | <entry><varname>Before=</varname></entry> | |
1256 | <entry><varname>After=</varname></entry> | |
1257 | <entry morerows='1' valign='middle'>Both are unit file options</entry> | |
1258 | </row> | |
1259 | <row> | |
1260 | <entry><varname>After=</varname></entry> | |
1261 | <entry><varname>Before=</varname></entry> | |
1262 | </row> | |
1263 | <row> | |
1264 | <entry><varname>Requires=</varname></entry> | |
1265 | <entry><varname>RequiredBy=</varname></entry> | |
1266 | <entry>A unit file option; an option in the [Install] section</entry> | |
1267 | </row> | |
1268 | <row> | |
1269 | <entry><varname>Wants=</varname></entry> | |
1270 | <entry><varname>WantedBy=</varname></entry> | |
1271 | <entry>A unit file option; an option in the [Install] section</entry> | |
1272 | </row> | |
1273 | <row> | |
1274 | <entry><varname>PartOf=</varname></entry> | |
1275 | <entry><varname>ConsistsOf=</varname></entry> | |
1276 | <entry>A unit file option; an automatic property</entry> | |
1277 | </row> | |
1278 | <row> | |
1279 | <entry><varname>BindsTo=</varname></entry> | |
1280 | <entry><varname>BoundBy=</varname></entry> | |
1281 | <entry>A unit file option; an automatic property</entry> | |
1282 | </row> | |
1283 | <row> | |
1284 | <entry><varname>Requisite=</varname></entry> | |
1285 | <entry><varname>RequisiteOf=</varname></entry> | |
1286 | <entry>A unit file option; an automatic property</entry> | |
1287 | </row> | |
1288 | <row> | |
1289 | <entry><varname>Triggers=</varname></entry> | |
1290 | <entry><varname>TriggeredBy=</varname></entry> | |
1291 | <entry>Automatic properties, see notes below</entry> | |
1292 | </row> | |
1293 | <row> | |
1294 | <entry><varname>Conflicts=</varname></entry> | |
1295 | <entry><varname>ConflictedBy=</varname></entry> | |
1296 | <entry>A unit file option; an automatic property</entry> | |
1297 | </row> | |
1298 | <row> | |
1299 | <entry><varname>PropagatesReloadTo=</varname></entry> | |
1300 | <entry><varname>ReloadPropagatedFrom=</varname></entry> | |
1301 | <entry morerows='1' valign='middle'>Both are unit file options</entry> | |
1302 | </row> | |
1303 | <row> | |
1304 | <entry><varname>ReloadPropagatedFrom=</varname></entry> | |
1305 | <entry><varname>PropagatesReloadTo=</varname></entry> | |
1306 | </row> | |
1307 | </tbody> | |
1308 | </tgroup> | |
1309 | </table> | |
798d3a52 | 1310 | |
2bf92506 ZJS |
1311 | <para>Note: <varname>WantedBy=</varname> and <varname>RequiredBy=</varname> are |
1312 | used in the [Install] section to create symlinks in <filename>.wants/</filename> | |
1313 | and <filename>.requires/</filename> directories. They cannot be used directly as a | |
1314 | unit configuration setting.</para> | |
1315 | ||
1316 | <para>Note: <varname>ConsistsOf=</varname>, <varname>BoundBy=</varname>, | |
1317 | <varname>RequisiteOf=</varname>, <varname>ConflictedBy=</varname> are created | |
1318 | implicitly along with their reverse and cannot be specified directly.</para> | |
1319 | ||
1320 | <para>Note: <varname>Triggers=</varname> is created implicitly between a socket, | |
1321 | path unit, or an automount unit, and the unit they activate. By default a unit | |
1322 | with the same name is triggered, but this can be overriden using | |
1323 | <varname>Sockets=</varname>, <varname>Service=</varname>, and <varname>Unit=</varname> | |
1324 | settings. See | |
1325 | <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
1326 | <citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
1327 | <citerefentry><refentrytitle>systemd.path</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
1328 | and | |
1329 | <citerefentry><refentrytitle>systemd.automount</refentrytitle><manvolnum>5</manvolnum></citerefentry> | |
1330 | for details. <varname>TriggersBy=</varname> is created implicitly on the | |
1331 | triggered unit.</para> | |
798d3a52 ZJS |
1332 | </refsect1> |
1333 | ||
1334 | <refsect1> | |
1335 | <title>[Install] Section Options</title> | |
1336 | ||
be73bb48 LP |
1337 | <para>Unit files may include an <literal>[Install]</literal> section, which carries installation information for |
1338 | the unit. This section is not interpreted by | |
1339 | <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry> during runtime; it is | |
1340 | used by the <command>enable</command> and <command>disable</command> commands of the | |
1341 | <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry> tool during | |
caa45f5b | 1342 | installation of a unit.</para> |
798d3a52 ZJS |
1343 | |
1344 | <variablelist class='unit-directives'> | |
1345 | <varlistentry> | |
1346 | <term><varname>Alias=</varname></term> | |
1347 | ||
f4bf8d2f | 1348 | <listitem><para>A space-separated list of additional names this unit shall be installed under. The names listed |
1245e413 | 1349 | here must have the same suffix (i.e. type) as the unit filename. This option may be specified more than once, |
f4bf8d2f LP |
1350 | in which case all listed names are used. At installation time, <command>systemctl enable</command> will create |
1351 | symlinks from these names to the unit filename. Note that not all unit types support such alias names, and this | |
1352 | setting is not supported for them. Specifically, mount, slice, swap, and automount units do not support | |
1353 | aliasing.</para></listitem> | |
798d3a52 ZJS |
1354 | </varlistentry> |
1355 | ||
1356 | <varlistentry> | |
1357 | <term><varname>WantedBy=</varname></term> | |
1358 | <term><varname>RequiredBy=</varname></term> | |
1359 | ||
1360 | <listitem><para>This option may be used more than once, or a | |
1361 | space-separated list of unit names may be given. A symbolic | |
1362 | link is created in the <filename>.wants/</filename> or | |
1363 | <filename>.requires/</filename> directory of each of the | |
1364 | listed units when this unit is installed by <command>systemctl | |
1365 | enable</command>. This has the effect that a dependency of | |
1366 | type <varname>Wants=</varname> or <varname>Requires=</varname> | |
1367 | is added from the listed unit to the current unit. The primary | |
1368 | result is that the current unit will be started when the | |
1369 | listed unit is started. See the description of | |
1370 | <varname>Wants=</varname> and <varname>Requires=</varname> in | |
1371 | the [Unit] section for details.</para> | |
1372 | ||
1373 | <para><command>WantedBy=foo.service</command> in a service | |
1374 | <filename>bar.service</filename> is mostly equivalent to | |
1375 | <command>Alias=foo.service.wants/bar.service</command> in the | |
1376 | same file. In case of template units, <command>systemctl | |
1377 | enable</command> must be called with an instance name, and | |
1378 | this instance will be added to the | |
1379 | <filename>.wants/</filename> or | |
1380 | <filename>.requires/</filename> list of the listed unit. E.g. | |
1381 | <command>WantedBy=getty.target</command> in a service | |
1382 | <filename>getty@.service</filename> will result in | |
1383 | <command>systemctl enable getty@tty2.service</command> | |
1384 | creating a | |
1385 | <filename>getty.target.wants/getty@tty2.service</filename> | |
1386 | link to <filename>getty@.service</filename>. | |
1387 | </para></listitem> | |
1388 | </varlistentry> | |
1389 | ||
1390 | <varlistentry> | |
1391 | <term><varname>Also=</varname></term> | |
1392 | ||
1393 | <listitem><para>Additional units to install/deinstall when | |
1394 | this unit is installed/deinstalled. If the user requests | |
1395 | installation/deinstallation of a unit with this option | |
1396 | configured, <command>systemctl enable</command> and | |
1397 | <command>systemctl disable</command> will automatically | |
1398 | install/uninstall units listed in this option as well.</para> | |
1399 | ||
1400 | <para>This option may be used more than once, or a | |
1401 | space-separated list of unit names may be | |
1402 | given.</para></listitem> | |
1403 | </varlistentry> | |
1404 | ||
1405 | <varlistentry> | |
1406 | <term><varname>DefaultInstance=</varname></term> | |
1407 | ||
1408 | <listitem><para>In template unit files, this specifies for | |
1409 | which instance the unit shall be enabled if the template is | |
1410 | enabled without any explicitly set instance. This option has | |
1411 | no effect in non-template unit files. The specified string | |
1412 | must be usable as instance identifier.</para></listitem> | |
1413 | </varlistentry> | |
1414 | </variablelist> | |
1415 | ||
1416 | <para>The following specifiers are interpreted in the Install | |
1417 | section: %n, %N, %p, %i, %U, %u, %m, %H, %b, %v. For their meaning | |
1418 | see the next section. | |
1419 | </para> | |
1420 | </refsect1> | |
1421 | ||
1422 | <refsect1> | |
1423 | <title>Specifiers</title> | |
1424 | ||
1425 | <para>Many settings resolve specifiers which may be used to write | |
1426 | generic unit files referring to runtime or unit parameters that | |
751223fe ZJS |
1427 | are replaced when the unit files are loaded. Specifiers must be known |
1428 | and resolvable for the setting to be valid. The following | |
798d3a52 ZJS |
1429 | specifiers are understood:</para> |
1430 | ||
1431 | <table> | |
1432 | <title>Specifiers available in unit files</title> | |
1433 | <tgroup cols='3' align='left' colsep='1' rowsep='1'> | |
1434 | <colspec colname="spec" /> | |
1435 | <colspec colname="mean" /> | |
1436 | <colspec colname="detail" /> | |
1437 | <thead> | |
1438 | <row> | |
5a15caf4 ZJS |
1439 | <entry>Specifier</entry> |
1440 | <entry>Meaning</entry> | |
1441 | <entry>Details</entry> | |
798d3a52 ZJS |
1442 | </row> |
1443 | </thead> | |
1444 | <tbody> | |
1445 | <row> | |
5a15caf4 ZJS |
1446 | <entry><literal>%n</literal></entry> |
1447 | <entry>Full unit name</entry> | |
1448 | <entry></entry> | |
798d3a52 ZJS |
1449 | </row> |
1450 | <row> | |
5a15caf4 ZJS |
1451 | <entry><literal>%N</literal></entry> |
1452 | <entry>Unescaped full unit name</entry> | |
1453 | <entry>Same as <literal>%n</literal>, but with escaping undone. This undoes the escaping used when generating unit names from arbitrary strings (see above). </entry> | |
798d3a52 ZJS |
1454 | </row> |
1455 | <row> | |
5a15caf4 ZJS |
1456 | <entry><literal>%p</literal></entry> |
1457 | <entry>Prefix name</entry> | |
1458 | <entry>For instantiated units, this refers to the string before the <literal>@</literal> character of the unit name. For non-instantiated units, this refers to the name of the unit with the type suffix removed.</entry> | |
798d3a52 ZJS |
1459 | </row> |
1460 | <row> | |
5a15caf4 ZJS |
1461 | <entry><literal>%P</literal></entry> |
1462 | <entry>Unescaped prefix name</entry> | |
1463 | <entry>Same as <literal>%p</literal>, but with escaping undone</entry> | |
798d3a52 ZJS |
1464 | </row> |
1465 | <row> | |
5a15caf4 ZJS |
1466 | <entry><literal>%i</literal></entry> |
1467 | <entry>Instance name</entry> | |
1468 | <entry>For instantiated units: this is the string between the <literal>@</literal> character and the suffix of the unit name.</entry> | |
798d3a52 ZJS |
1469 | </row> |
1470 | <row> | |
5a15caf4 ZJS |
1471 | <entry><literal>%I</literal></entry> |
1472 | <entry>Unescaped instance name</entry> | |
1473 | <entry>Same as <literal>%i</literal>, but with escaping undone</entry> | |
798d3a52 ZJS |
1474 | </row> |
1475 | <row> | |
5a15caf4 ZJS |
1476 | <entry><literal>%f</literal></entry> |
1477 | <entry>Unescaped filename</entry> | |
1478 | <entry>This is either the unescaped instance name (if applicable) with <filename>/</filename> prepended (if applicable), or the unescaped prefix name prepended with <filename>/</filename>. This implements unescaping according to the rules for escaping absolute file system paths discussed above.</entry> | |
798d3a52 ZJS |
1479 | </row> |
1480 | <row> | |
5a15caf4 ZJS |
1481 | <entry><literal>%t</literal></entry> |
1482 | <entry>Runtime directory root</entry> | |
1483 | <entry>This is either <filename>/run</filename> (for the system manager) or the path <literal>$XDG_RUNTIME_DIR</literal> resolves to (for user managers).</entry> | |
798d3a52 ZJS |
1484 | </row> |
1485 | <row> | |
5a15caf4 ZJS |
1486 | <entry><literal>%S</literal></entry> |
1487 | <entry>State directory root</entry> | |
1488 | <entry>This is either <filename>/var/lib</filename> (for the system manager) or the path <literal>$XDG_CONFIG_HOME</literal> resolves to (for user managers).</entry> | |
14068e17 LP |
1489 | </row> |
1490 | <row> | |
5a15caf4 ZJS |
1491 | <entry><literal>%C</literal></entry> |
1492 | <entry>Cache directory root</entry> | |
1493 | <entry>This is either <filename>/var/cache</filename> (for the system manager) or the path <literal>$XDG_CACHE_HOME</literal> resolves to (for user managers).</entry> | |
14068e17 LP |
1494 | </row> |
1495 | <row> | |
5a15caf4 ZJS |
1496 | <entry><literal>%L</literal></entry> |
1497 | <entry>Log directory root</entry> | |
1498 | <entry>This is either <filename>/var/log</filename> (for the system manager) or the path <literal>$XDG_CONFIG_HOME</literal> resolves to with <filename noindex='true'>/log</filename> appended (for user managers).</entry> | |
14068e17 LP |
1499 | </row> |
1500 | <row> | |
5a15caf4 ZJS |
1501 | <entry><literal>%u</literal></entry> |
1502 | <entry>User name</entry> | |
1503 | <entry>This is the name of the user running the service manager instance. In case of the system manager this resolves to <literal>root</literal>.</entry> | |
798d3a52 ZJS |
1504 | </row> |
1505 | <row> | |
5a15caf4 ZJS |
1506 | <entry><literal>%U</literal></entry> |
1507 | <entry>User UID</entry> | |
1508 | <entry>This is the numeric UID of the user running the service manager instance. In case of the system manager this resolves to <literal>0</literal>.</entry> | |
798d3a52 ZJS |
1509 | </row> |
1510 | <row> | |
5a15caf4 ZJS |
1511 | <entry><literal>%h</literal></entry> |
1512 | <entry>User home directory</entry> | |
1513 | <entry>This is the home directory of the user running the service manager instance. In case of the system manager this resolves to <literal>/root</literal>.</entry> | |
798d3a52 ZJS |
1514 | </row> |
1515 | <row> | |
5a15caf4 ZJS |
1516 | <entry><literal>%s</literal></entry> |
1517 | <entry>User shell</entry> | |
1518 | <entry>This is the shell of the user running the service manager instance. In case of the system manager this resolves to <literal>/bin/sh</literal>.</entry> | |
798d3a52 ZJS |
1519 | </row> |
1520 | <row> | |
5a15caf4 ZJS |
1521 | <entry><literal>%m</literal></entry> |
1522 | <entry>Machine ID</entry> | |
1523 | <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> | |
798d3a52 ZJS |
1524 | </row> |
1525 | <row> | |
5a15caf4 ZJS |
1526 | <entry><literal>%b</literal></entry> |
1527 | <entry>Boot ID</entry> | |
1528 | <entry>The boot ID of the running system, formatted as string. See <citerefentry><refentrytitle>random</refentrytitle><manvolnum>4</manvolnum></citerefentry> for more information.</entry> | |
798d3a52 ZJS |
1529 | </row> |
1530 | <row> | |
5a15caf4 ZJS |
1531 | <entry><literal>%H</literal></entry> |
1532 | <entry>Host name</entry> | |
1533 | <entry>The hostname of the running system at the point in time the unit configuration is loaded.</entry> | |
798d3a52 ZJS |
1534 | </row> |
1535 | <row> | |
5a15caf4 ZJS |
1536 | <entry><literal>%v</literal></entry> |
1537 | <entry>Kernel release</entry> | |
1538 | <entry>Identical to <command>uname -r</command> output</entry> | |
798d3a52 ZJS |
1539 | </row> |
1540 | <row> | |
5a15caf4 ZJS |
1541 | <entry><literal>%%</literal></entry> |
1542 | <entry>Single percent sign</entry> | |
1543 | <entry>Use <literal>%%</literal> in place of <literal>%</literal> to specify a single percent sign.</entry> | |
798d3a52 ZJS |
1544 | </row> |
1545 | </tbody> | |
1546 | </tgroup> | |
1547 | </table> | |
798d3a52 ZJS |
1548 | </refsect1> |
1549 | ||
1550 | <refsect1> | |
1551 | <title>Examples</title> | |
1552 | ||
1553 | <example> | |
1554 | <title>Allowing units to be enabled</title> | |
1555 | ||
1556 | <para>The following snippet (highlighted) allows a unit (e.g. | |
1557 | <filename>foo.service</filename>) to be enabled via | |
1558 | <command>systemctl enable</command>:</para> | |
1559 | ||
1560 | <programlisting>[Unit] | |
92b1e225 CS |
1561 | Description=Foo |
1562 | ||
1563 | [Service] | |
1564 | ExecStart=/usr/sbin/foo-daemon | |
1565 | ||
1566 | <emphasis>[Install]</emphasis> | |
1567 | <emphasis>WantedBy=multi-user.target</emphasis></programlisting> | |
1568 | ||
798d3a52 ZJS |
1569 | <para>After running <command>systemctl enable</command>, a |
1570 | symlink | |
12b42c76 | 1571 | <filename>/etc/systemd/system/multi-user.target.wants/foo.service</filename> |
798d3a52 ZJS |
1572 | linking to the actual unit will be created. It tells systemd to |
1573 | pull in the unit when starting | |
1574 | <filename>multi-user.target</filename>. The inverse | |
1575 | <command>systemctl disable</command> will remove that symlink | |
1576 | again.</para> | |
1577 | </example> | |
1578 | ||
1579 | <example> | |
1580 | <title>Overriding vendor settings</title> | |
1581 | ||
1582 | <para>There are two methods of overriding vendor settings in | |
1583 | unit files: copying the unit file from | |
12b42c76 TG |
1584 | <filename>/usr/lib/systemd/system</filename> to |
1585 | <filename>/etc/systemd/system</filename> and modifying the | |
798d3a52 ZJS |
1586 | chosen settings. Alternatively, one can create a directory named |
1587 | <filename><replaceable>unit</replaceable>.d/</filename> within | |
12b42c76 | 1588 | <filename>/etc/systemd/system</filename> and place a drop-in |
798d3a52 ZJS |
1589 | file <filename><replaceable>name</replaceable>.conf</filename> |
1590 | there that only changes the specific settings one is interested | |
1591 | in. Note that multiple such drop-in files are read if | |
8331eaab | 1592 | present, processed in lexicographic order of their filename.</para> |
798d3a52 ZJS |
1593 | |
1594 | <para>The advantage of the first method is that one easily | |
1595 | overrides the complete unit, the vendor unit is not parsed at | |
1596 | all anymore. It has the disadvantage that improvements to the | |
1597 | unit file by the vendor are not automatically incorporated on | |
1598 | updates.</para> | |
1599 | ||
1600 | <para>The advantage of the second method is that one only | |
1601 | overrides the settings one specifically wants, where updates to | |
1602 | the unit by the vendor automatically apply. This has the | |
1603 | disadvantage that some future updates by the vendor might be | |
1604 | incompatible with the local changes.</para> | |
1605 | ||
1606 | <para>Note that for drop-in files, if one wants to remove | |
1607 | entries from a setting that is parsed as a list (and is not a | |
1608 | dependency), such as <varname>ConditionPathExists=</varname> (or | |
1609 | e.g. <varname>ExecStart=</varname> in service units), one needs | |
1610 | to first clear the list before re-adding all entries except the | |
1611 | one that is to be removed. See below for an example.</para> | |
1612 | ||
1613 | <para>This also applies for user instances of systemd, but with | |
1614 | different locations for the unit files. See the section on unit | |
1615 | load paths for further details.</para> | |
1616 | ||
1617 | <para>Suppose there is a vendor-supplied unit | |
12b42c76 | 1618 | <filename>/usr/lib/systemd/system/httpd.service</filename> with |
798d3a52 ZJS |
1619 | the following contents:</para> |
1620 | ||
1621 | <programlisting>[Unit] | |
92b1e225 CS |
1622 | Description=Some HTTP server |
1623 | After=remote-fs.target sqldb.service | |
1624 | Requires=sqldb.service | |
1625 | AssertPathExists=/srv/webserver | |
1626 | ||
1627 | [Service] | |
1628 | Type=notify | |
1629 | ExecStart=/usr/sbin/some-fancy-httpd-server | |
1630 | Nice=5 | |
1631 | ||
1632 | [Install] | |
1633 | WantedBy=multi-user.target</programlisting> | |
1634 | ||
798d3a52 ZJS |
1635 | <para>Now one wants to change some settings as an administrator: |
1636 | firstly, in the local setup, <filename>/srv/webserver</filename> | |
e2acdb6b | 1637 | might not exist, because the HTTP server is configured to use |
798d3a52 ZJS |
1638 | <filename>/srv/www</filename> instead. Secondly, the local |
1639 | configuration makes the HTTP server also depend on a memory | |
1640 | cache service, <filename>memcached.service</filename>, that | |
1641 | should be pulled in (<varname>Requires=</varname>) and also be | |
1642 | ordered appropriately (<varname>After=</varname>). Thirdly, in | |
1643 | order to harden the service a bit more, the administrator would | |
1644 | like to set the <varname>PrivateTmp=</varname> setting (see | |
912f003f | 1645 | <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry> |
798d3a52 ZJS |
1646 | for details). And lastly, the administrator would like to reset |
1647 | the niceness of the service to its default value of 0.</para> | |
1648 | ||
1649 | <para>The first possibility is to copy the unit file to | |
12b42c76 | 1650 | <filename>/etc/systemd/system/httpd.service</filename> and |
798d3a52 ZJS |
1651 | change the chosen settings:</para> |
1652 | ||
1653 | <programlisting>[Unit] | |
92b1e225 CS |
1654 | Description=Some HTTP server |
1655 | After=remote-fs.target sqldb.service <emphasis>memcached.service</emphasis> | |
1656 | Requires=sqldb.service <emphasis>memcached.service</emphasis> | |
1657 | AssertPathExists=<emphasis>/srv/www</emphasis> | |
1658 | ||
1659 | [Service] | |
1660 | Type=notify | |
1661 | ExecStart=/usr/sbin/some-fancy-httpd-server | |
1662 | <emphasis>Nice=0</emphasis> | |
1663 | <emphasis>PrivateTmp=yes</emphasis> | |
1664 | ||
1665 | [Install] | |
1666 | WantedBy=multi-user.target</programlisting> | |
1667 | ||
798d3a52 ZJS |
1668 | <para>Alternatively, the administrator could create a drop-in |
1669 | file | |
12b42c76 | 1670 | <filename>/etc/systemd/system/httpd.service.d/local.conf</filename> |
798d3a52 | 1671 | with the following contents:</para> |
92b1e225 | 1672 | |
798d3a52 | 1673 | <programlisting>[Unit] |
92b1e225 CS |
1674 | After=memcached.service |
1675 | Requires=memcached.service | |
1676 | # Reset all assertions and then re-add the condition we want | |
1677 | AssertPathExists= | |
1678 | AssertPathExists=/srv/www | |
1679 | ||
1680 | [Service] | |
1681 | Nice=0 | |
1682 | PrivateTmp=yes</programlisting> | |
1683 | ||
798d3a52 ZJS |
1684 | <para>Note that dependencies (<varname>After=</varname>, etc.) |
1685 | cannot be reset to an empty list, so dependencies can only be | |
1686 | added in drop-ins. If you want to remove dependencies, you have | |
1687 | to override the entire unit.</para> | |
0cf4c0d1 | 1688 | |
798d3a52 ZJS |
1689 | </example> |
1690 | </refsect1> | |
1691 | ||
1692 | <refsect1> | |
1693 | <title>See Also</title> | |
1694 | <para> | |
1695 | <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>, | |
1696 | <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>, | |
1697 | <citerefentry><refentrytitle>systemd.special</refentrytitle><manvolnum>7</manvolnum></citerefentry>, | |
1698 | <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
1699 | <citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
1700 | <citerefentry><refentrytitle>systemd.device</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
1701 | <citerefentry><refentrytitle>systemd.mount</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
1702 | <citerefentry><refentrytitle>systemd.automount</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
1703 | <citerefentry><refentrytitle>systemd.swap</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
1704 | <citerefentry><refentrytitle>systemd.target</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
1705 | <citerefentry><refentrytitle>systemd.path</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
1706 | <citerefentry><refentrytitle>systemd.timer</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
798d3a52 ZJS |
1707 | <citerefentry><refentrytitle>systemd.scope</refentrytitle><manvolnum>5</manvolnum></citerefentry>, |
1708 | <citerefentry><refentrytitle>systemd.slice</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
1709 | <citerefentry><refentrytitle>systemd.time</refentrytitle><manvolnum>7</manvolnum></citerefentry>, | |
1710 | <citerefentry><refentrytitle>systemd-analyze</refentrytitle><manvolnum>1</manvolnum></citerefentry>, | |
1711 | <citerefentry project='man-pages'><refentrytitle>capabilities</refentrytitle><manvolnum>7</manvolnum></citerefentry>, | |
1712 | <citerefentry><refentrytitle>systemd.directives</refentrytitle><manvolnum>7</manvolnum></citerefentry>, | |
3ba3a79d | 1713 | <citerefentry project='man-pages'><refentrytitle>uname</refentrytitle><manvolnum>1</manvolnum></citerefentry> |
798d3a52 ZJS |
1714 | </para> |
1715 | </refsect1> | |
d1ab0ca0 LP |
1716 | |
1717 | </refentry> |