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