]> git.ipfire.org Git - thirdparty/systemd.git/blob - man/systemd.target.xml
Merge pull request #12753 from jrouleau/fix/hibernate-resume-timeout
[thirdparty/systemd.git] / man / systemd.target.xml
1 <?xml version='1.0'?> <!--*-nxml-*-->
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
4 <!-- SPDX-License-Identifier: LGPL-2.1+ -->
5
6 <refentry id="systemd.target">
7 <refentryinfo>
8 <title>systemd.target</title>
9 <productname>systemd</productname>
10 </refentryinfo>
11
12 <refmeta>
13 <refentrytitle>systemd.target</refentrytitle>
14 <manvolnum>5</manvolnum>
15 </refmeta>
16
17 <refnamediv>
18 <refname>systemd.target</refname>
19 <refpurpose>Target unit configuration</refpurpose>
20 </refnamediv>
21
22 <refsynopsisdiv>
23 <para><filename><replaceable>target</replaceable>.target</filename></para>
24 </refsynopsisdiv>
25
26 <refsect1>
27 <title>Description</title>
28
29 <para>A unit configuration file whose name ends in
30 <literal>.target</literal> encodes information about a target unit
31 of systemd, which is used for grouping units and as well-known
32 synchronization points during start-up.</para>
33
34 <para>This unit type has no specific options. See
35 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>
36 for the common options of all unit configuration files. The common
37 configuration items are configured in the generic <literal>[Unit]</literal> and
38 <literal>[Install]</literal> sections. A separate <literal>[Target]</literal> section does not exist,
39 since no target-specific options may be configured.</para>
40
41 <para>Target units do not offer any additional functionality on
42 top of the generic functionality provided by units. They exist
43 merely to group units via dependencies (useful as boot targets),
44 and to establish standardized names for synchronization points
45 used in dependencies between units. Among other things, target
46 units are a more flexible replacement for SysV runlevels in the
47 classic SysV init system. (And for compatibility reasons special
48 target units such as <filename>runlevel3.target</filename> exist
49 which are used by the SysV runlevel compatibility code in systemd.
50 See
51 <citerefentry><refentrytitle>systemd.special</refentrytitle><manvolnum>7</manvolnum></citerefentry>
52 for details).</para>
53 </refsect1>
54
55 <refsect1>
56 <title>Automatic Dependencies</title>
57
58 <refsect2>
59 <title>Implicit Dependencies</title>
60
61 <para>There are no implicit dependencies for target units.</para>
62 </refsect2>
63
64 <refsect2>
65 <title>Default Dependencies</title>
66
67 <para>The following dependencies are added unless
68 <varname>DefaultDependencies=no</varname> is set:</para>
69
70 <itemizedlist>
71 <listitem><para>Target units will automatically complement all
72 configured dependencies of type <varname>Wants=</varname> or
73 <varname>Requires=</varname> with dependencies of type
74 <varname>After=</varname> unless <varname>DefaultDependencies=no</varname>
75 is set in the specified units. Note that <varname>Wants=</varname> or
76 <varname>Requires=</varname> must be defined in the target unit itself — if
77 you for example define <varname>Wants=</varname>some.target in
78 some.service, the automatic ordering will not be added.</para></listitem>
79
80 <listitem><para>Target units automatically gain <varname>Conflicts=</varname>
81 and <varname>Before=</varname> dependencies against
82 <filename>shutdown.target</filename>.</para></listitem>
83 </itemizedlist>
84 </refsect2>
85 </refsect1>
86
87 <refsect1>
88 <title>Example</title>
89
90 <example>
91 <title>Simple standalone target</title>
92
93 <programlisting># emergency-net.target
94
95 [Unit]
96 Description=Emergency Mode with Networking
97 Requires=emergency.target systemd-networkd.service
98 After=emergency.target systemd-networkd.service
99 AllowIsolate=yes</programlisting>
100
101 <para>When adding dependencies to other units, it's important to check if they set
102 <varname>DefaultDependencies=</varname>. Service units, unless they set
103 <varname>DefaultDependencies=no</varname>, automatically get a dependency on
104 <filename>sysinit.target</filename>. In this case, both
105 <filename>emergency.target</filename> and <filename>systemd-networkd.service</filename>
106 have <varname>DefaultDependencies=no</varname>, so they are suitable for use
107 in this target, and do not pull in <filename>sysinit.target</filename>.</para>
108
109 <para>You can now switch into this emergency mode by running <varname>systemctl
110 isolate emergency-net.target</varname> or by passing the option
111 <varname>systemd.unit=emergency-net.target</varname> on the kernel command
112 line.</para>
113
114 <para>Other units can have <varname>WantedBy=emergency-net.target</varname> in the
115 <varname>[Install]</varname> section. After they are enabled using
116 <command>systemctl enable</command>, they will be started before
117 <varname>emergency-net.target</varname> is started. It is also possible to add
118 arbitrary units as dependencies of <filename>emergency.target</filename> without
119 modifying them by using <command>systemctl add-wants</command>.
120 </para>
121 </example>
122 </refsect1>
123
124 <refsect1>
125 <title>See Also</title>
126 <para>
127 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
128 <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
129 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
130 <citerefentry><refentrytitle>systemd.special</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
131 <citerefentry><refentrytitle>systemd.directives</refentrytitle><manvolnum>7</manvolnum></citerefentry>
132 </para>
133 </refsect1>
134
135 </refentry>