| 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.5/docbookx.dtd"> |
| 4 |
<!-- SPDX-License-Identifier: LGPL-2.1-or-later --> |
| 5 |
|
| 6 |
<refentry id="systemd.path" xmlns:xi="http://www.w3.org/2001/XInclude"> |
| 7 |
<refentryinfo> |
| 8 |
<title>systemd.path</title> |
| 9 |
<productname>systemd</productname> |
| 10 |
</refentryinfo> |
| 11 |
|
| 12 |
<refmeta> |
| 13 |
<refentrytitle>systemd.path</refentrytitle> |
| 14 |
<manvolnum>5</manvolnum> |
| 15 |
</refmeta> |
| 16 |
|
| 17 |
<refnamediv> |
| 18 |
<refname>systemd.path</refname> |
| 19 |
<refpurpose>Path unit configuration</refpurpose> |
| 20 |
</refnamediv> |
| 21 |
|
| 22 |
<refsynopsisdiv> |
| 23 |
<para><filename><replaceable>path</replaceable>.path</filename></para> |
| 24 |
</refsynopsisdiv> |
| 25 |
|
| 26 |
<refsect1> |
| 27 |
<title>Description</title> |
| 28 |
|
| 29 |
<para>A unit configuration file whose name ends in |
| 30 |
<literal>.path</literal> encodes information about a path |
| 31 |
monitored by systemd, for path-based activation.</para> |
| 32 |
|
| 33 |
<para>This man page lists the configuration options specific to |
| 34 |
this unit type. 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 [Unit] and |
| 38 |
[Install] sections. The path specific configuration options are |
| 39 |
configured in the [Path] section.</para> |
| 40 |
|
| 41 |
<para>For each path file, a matching unit file must exist, |
| 42 |
describing the unit to activate when the path changes. By default, |
| 43 |
a service by the same name as the path (except for the suffix) is |
| 44 |
activated. Example: a path file <filename>foo.path</filename> |
| 45 |
activates a matching service <filename>foo.service</filename>. The |
| 46 |
unit to activate may be controlled by <varname>Unit=</varname> |
| 47 |
(see below).</para> |
| 48 |
|
| 49 |
<para>Internally, path units use the |
| 50 |
<citerefentry project='man-pages'><refentrytitle>inotify</refentrytitle><manvolnum>7</manvolnum></citerefentry> |
| 51 |
API to monitor file systems. Due to that, it suffers by the same |
| 52 |
limitations as inotify, and for example cannot be used to monitor |
| 53 |
files or directories changed by other machines on remote NFS file |
| 54 |
systems.</para> |
| 55 |
|
| 56 |
<para>When a service unit triggered by a path unit terminates (regardless whether it exited successfully |
| 57 |
or failed), monitored paths are checked immediately again, and the service accordingly restarted |
| 58 |
instantly. As protection against busy looping in this trigger/start cycle, a start rate limit is enforced |
| 59 |
on the service unit, see <varname>StartLimitIntervalSec=</varname> and |
| 60 |
<varname>StartLimitBurst=</varname> in |
| 61 |
<citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>. Unlike |
| 62 |
other service failures, the error condition that the start rate limit is hit is propagated from the |
| 63 |
service unit to the path unit and causes the path unit to fail as well, thus ending the loop.</para> |
| 64 |
</refsect1> |
| 65 |
|
| 66 |
<refsect1> |
| 67 |
<title>Automatic Dependencies</title> |
| 68 |
|
| 69 |
<refsect2> |
| 70 |
<title>Implicit Dependencies</title> |
| 71 |
|
| 72 |
<para>The following dependencies are implicitly added:</para> |
| 73 |
|
| 74 |
<itemizedlist> |
| 75 |
<listitem><para>If a path unit is beneath another mount unit in the file |
| 76 |
system hierarchy, both a requirement and an ordering dependency |
| 77 |
between both units are created automatically.</para></listitem> |
| 78 |
|
| 79 |
<listitem><para>An implicit <varname>Before=</varname> dependency is added |
| 80 |
between a path unit and the unit it is supposed to activate.</para></listitem> |
| 81 |
</itemizedlist> |
| 82 |
</refsect2> |
| 83 |
|
| 84 |
<refsect2> |
| 85 |
<title>Default Dependencies</title> |
| 86 |
|
| 87 |
<para>The following dependencies are added unless <varname>DefaultDependencies=no</varname> is set:</para> |
| 88 |
|
| 89 |
<itemizedlist> |
| 90 |
<listitem><para>Path units will automatically have dependencies of type <varname>Before=</varname> on |
| 91 |
<filename>paths.target</filename>, |
| 92 |
dependencies of type <varname>After=</varname> and <varname>Requires=</varname> on |
| 93 |
<filename>sysinit.target</filename>, and have dependencies of type <varname>Conflicts=</varname> and |
| 94 |
<varname>Before=</varname> on <filename>shutdown.target</filename>. These ensure that path units are terminated |
| 95 |
cleanly prior to system shutdown. Only path units involved with early boot or late system shutdown should |
| 96 |
disable <varname>DefaultDependencies=</varname> option.</para></listitem> |
| 97 |
</itemizedlist> |
| 98 |
|
| 99 |
<para></para> |
| 100 |
</refsect2> |
| 101 |
</refsect1> |
| 102 |
|
| 103 |
<refsect1> |
| 104 |
<title>Options</title> |
| 105 |
|
| 106 |
<para>Path unit files may include [Unit] and [Install] sections, which are described in |
| 107 |
<citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>. |
| 108 |
</para> |
| 109 |
|
| 110 |
<para>Path unit files must include a [Path] section, which carries information about the path or paths it |
| 111 |
monitors. The options specific to the [Path] section of path units are the following:</para> |
| 112 |
|
| 113 |
<variablelist class='unit-directives'> |
| 114 |
<varlistentry> |
| 115 |
<term><varname>PathExists=</varname></term> |
| 116 |
<term><varname>PathExistsGlob=</varname></term> |
| 117 |
<term><varname>PathChanged=</varname></term> |
| 118 |
<term><varname>PathModified=</varname></term> |
| 119 |
<term><varname>DirectoryNotEmpty=</varname></term> |
| 120 |
|
| 121 |
<listitem><para>Defines paths to monitor for certain changes: |
| 122 |
<varname>PathExists=</varname> may be used to watch the mere |
| 123 |
existence of a file or directory. If the file specified |
| 124 |
exists, the configured unit is activated. |
| 125 |
<varname>PathExistsGlob=</varname> works similarly, but checks |
| 126 |
for the existence of at least one file matching the globbing |
| 127 |
pattern specified. <varname>PathChanged=</varname> may be used |
| 128 |
to watch a file or directory and activate the configured unit |
| 129 |
whenever it changes. It is not activated on every write to the |
| 130 |
watched file but it is activated if the file which was open |
| 131 |
for writing gets closed. <varname>PathModified=</varname> is |
| 132 |
similar, but additionally it is activated also on simple |
| 133 |
writes to the watched file. |
| 134 |
<varname>DirectoryNotEmpty=</varname> may be used to watch a |
| 135 |
directory and activate the configured unit whenever it |
| 136 |
contains at least one file.</para> |
| 137 |
|
| 138 |
<para>The arguments of these directives must be absolute file |
| 139 |
system paths.</para> |
| 140 |
|
| 141 |
<para>Multiple directives may be combined, of the same and of |
| 142 |
different types, to watch multiple paths. If the empty string |
| 143 |
is assigned to any of these options, the list of paths to |
| 144 |
watch is reset, and any prior assignments of these options |
| 145 |
will not have any effect.</para> |
| 146 |
|
| 147 |
<para>If a path already exists (in case of |
| 148 |
<varname>PathExists=</varname> and |
| 149 |
<varname>PathExistsGlob=</varname>) or a directory already is |
| 150 |
not empty (in case of <varname>DirectoryNotEmpty=</varname>) |
| 151 |
at the time the path unit is activated, then the configured |
| 152 |
unit is immediately activated as well. Something similar does |
| 153 |
not apply to <varname>PathChanged=</varname> and |
| 154 |
<varname>PathModified=</varname>.</para> |
| 155 |
|
| 156 |
<para>If the path itself or any of the containing directories are not accessible, |
| 157 |
<command>systemd</command> will watch for permission changes and notice that conditions are satisfied |
| 158 |
when permissions allow that. </para> |
| 159 |
|
| 160 |
<para>Note that files whose name starts with a dot (i.e. hidden files) are generally ignored when |
| 161 |
monitoring these paths.</para></listitem> |
| 162 |
</varlistentry> |
| 163 |
|
| 164 |
<varlistentry> |
| 165 |
<term><varname>Unit=</varname></term> |
| 166 |
|
| 167 |
<listitem><para>The unit to activate when any of the |
| 168 |
configured paths changes. The argument is a unit name, whose |
| 169 |
suffix is not <literal>.path</literal>. If not specified, this |
| 170 |
value defaults to a service that has the same name as the path |
| 171 |
unit, except for the suffix. (See above.) It is recommended |
| 172 |
that the unit name that is activated and the unit name of the |
| 173 |
path unit are named identical, except for the |
| 174 |
suffix.</para></listitem> |
| 175 |
</varlistentry> |
| 176 |
<varlistentry> |
| 177 |
<term><varname>MakeDirectory=</varname></term> |
| 178 |
|
| 179 |
<listitem><para>Takes a boolean argument. If true, the |
| 180 |
directories to watch are created before watching. This option |
| 181 |
is ignored for <varname>PathExists=</varname> settings. |
| 182 |
Defaults to <option>false</option>.</para></listitem> |
| 183 |
</varlistentry> |
| 184 |
<varlistentry> |
| 185 |
<term><varname>DirectoryMode=</varname></term> |
| 186 |
|
| 187 |
<listitem><para>If <varname>MakeDirectory=</varname> is |
| 188 |
enabled, use the mode specified here to create the directories |
| 189 |
in question. Takes an access mode in octal notation. Defaults |
| 190 |
to <option>0755</option>.</para></listitem> |
| 191 |
</varlistentry> |
| 192 |
<varlistentry> |
| 193 |
<term><varname>TriggerLimitIntervalSec=</varname></term> |
| 194 |
<term><varname>TriggerLimitBurst=</varname></term> |
| 195 |
|
| 196 |
<listitem><para>Configures a limit on how often this path unit may be activated within a specific |
| 197 |
time interval. The <varname>TriggerLimitIntervalSec=</varname> may be used to configure the length of |
| 198 |
the time interval in the usual time units <literal>us</literal>, <literal>ms</literal>, |
| 199 |
<literal>s</literal>, <literal>min</literal>, <literal>h</literal>, … and defaults to 2s. See |
| 200 |
<citerefentry><refentrytitle>systemd.time</refentrytitle><manvolnum>7</manvolnum></citerefentry> for |
| 201 |
details on the various time units understood. The <varname>TriggerLimitBurst=</varname> setting takes |
| 202 |
a positive integer value and specifies the number of permitted activations per time interval, and |
| 203 |
defaults to 200. Set either to 0 to disable any form of trigger rate limiting. If the limit is hit, |
| 204 |
the unit is placed into a failure mode, and will not watch the paths anymore until restarted. Note |
| 205 |
that this limit is enforced before the service activation is enqueued.</para> |
| 206 |
|
| 207 |
<xi:include href="version-info.xml" xpointer="v250"/></listitem> |
| 208 |
</varlistentry> |
| 209 |
</variablelist> |
| 210 |
|
| 211 |
<xi:include href="systemd.service.xml" xpointer="shared-unit-options" /> |
| 212 |
</refsect1> |
| 213 |
|
| 214 |
<refsect1> |
| 215 |
<title>See Also</title> |
| 216 |
<para>Environment variables with details on the trigger will be set for triggered units. See the |
| 217 |
section <literal>Environment Variables Set or Propagated by the Service Manager</literal> in |
| 218 |
<citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry> |
| 219 |
for more details.</para> |
| 220 |
<para><simplelist type="inline"> |
| 221 |
<member><citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry></member> |
| 222 |
<member><citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry></member> |
| 223 |
<member><citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry></member> |
| 224 |
<member><citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry></member> |
| 225 |
<member><citerefentry project='man-pages'><refentrytitle>inotify</refentrytitle><manvolnum>7</manvolnum></citerefentry></member> |
| 226 |
<member><citerefentry><refentrytitle>systemd.directives</refentrytitle><manvolnum>7</manvolnum></citerefentry></member> |
| 227 |
</simplelist></para> |
| 228 |
</refsect1> |
| 229 |
|
| 230 |
</refentry> |