]> git.ipfire.org Git - thirdparty/systemd.git/blame - man/tmpfiles.d.xml
man: document that removal/clean-up is done before creation in systemd-tmpfiles
[thirdparty/systemd.git] / man / tmpfiles.d.xml
CommitLineData
514094f9 1<?xml version='1.0'?>
12b42c76 2<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
4149f86d 3<!--
572eb058
ZJS
4 SPDX-License-Identifier: LGPL-2.1+
5
96b2fb93 6 Copyright © 2010 Brandon Philips
4149f86d
BP
7-->
8<refentry id="tmpfiles.d">
9
302fbdf2
ZJS
10 <refentryinfo>
11 <title>tmpfiles.d</title>
12 <productname>systemd</productname>
302fbdf2
ZJS
13 </refentryinfo>
14
15 <refmeta>
16 <refentrytitle>tmpfiles.d</refentrytitle>
17 <manvolnum>5</manvolnum>
18 </refmeta>
19
20 <refnamediv>
21 <refname>tmpfiles.d</refname>
22 <refpurpose>Configuration for creation, deletion and cleaning of
23 volatile and temporary files</refpurpose>
24 </refnamediv>
25
26 <refsynopsisdiv>
f2b5ca0e
ZJS
27 <para><literallayout><filename>/etc/tmpfiles.d/*.conf</filename>
28<filename>/run/tmpfiles.d/*.conf</filename>
29<filename>/usr/lib/tmpfiles.d/*.conf</filename>
30 </literallayout></para>
31
32 <para><literallayout><filename>~/.config/user-tmpfiles.d/*.conf</filename>
33<filename>$XDG_RUNTIME_DIR/user-tmpfiles.d/*.conf</filename>
34<filename>~/.local/share/user-tmpfiles.d/*.conf</filename>
35<filename>…</filename>
36<filename>/usr/share/user-tmpfiles.d/*.conf</filename>
37 </literallayout></para>
302fbdf2
ZJS
38 </refsynopsisdiv>
39
40 <refsect1>
41 <title>Description</title>
42
43 <para><command>systemd-tmpfiles</command> uses the configuration
44 files from the above directories to describe the creation,
45 cleaning and removal of volatile and temporary files and
46 directories which usually reside in directories such as
47 <filename>/run</filename> or <filename>/tmp</filename>.</para>
48
51c169c8
LP
49 <para>Volatile and temporary files and directories are those located in <filename>/run</filename>,
50 <filename>/tmp</filename>, <filename>/var/tmp</filename>, the API file systems such as <filename>/sys</filename> or
51 <filename>/proc</filename>, as well as some other directories below <filename>/var</filename>.</para>
302fbdf2
ZJS
52
53 <para>System daemons frequently require private runtime
54 directories below <filename>/run</filename> to place communication
55 sockets and similar in. For these, consider declaring them in
56 their unit files using <varname>RuntimeDirectory=</varname> (see
57 <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>
58 for details), if this is feasible.</para>
59 </refsect1>
60
61 <refsect1>
8165be2e 62 <title>Configuration Directories and Precedence</title>
302fbdf2
ZJS
63
64 <para>Each configuration file shall be named in the style of
65 <filename><replaceable>package</replaceable>.conf</filename> or
66 <filename><replaceable>package</replaceable>-<replaceable>part</replaceable>.conf</filename>.
67 The second variant should be used when it is desirable to make it
68 easy to override just this part of configuration.</para>
69
70 <para>Files in <filename>/etc/tmpfiles.d</filename> override files
71 with the same name in <filename>/usr/lib/tmpfiles.d</filename> and
72 <filename>/run/tmpfiles.d</filename>. Files in
73 <filename>/run/tmpfiles.d</filename> override files with the same
74 name in <filename>/usr/lib/tmpfiles.d</filename>. Packages should
75 install their configuration files in
76 <filename>/usr/lib/tmpfiles.d</filename>. Files in
77 <filename>/etc/tmpfiles.d</filename> are reserved for the local
78 administrator, who may use this logic to override the
79 configuration files installed by vendor packages. All
80 configuration files are sorted by their filename in lexicographic
81 order, regardless of which of the directories they reside in. If
82 multiple files specify the same path, the entry in the file with
83 the lexicographically earliest name will be applied. All other
84 conflicting entries will be logged as errors. When two lines are
85 prefix and suffix of each other, then the prefix is always
6d785b6d
LP
86 processed first, the suffix later. Lines that take globs are
87 applied after those accepting no globs. If multiple operations
b938cb90
JE
88 shall be applied on the same file, (such as ACL, xattr, file
89 attribute adjustments), these are always done in the same fixed
6d785b6d
LP
90 order. Otherwise, the files/directories are processed in the order
91 they are listed.</para>
302fbdf2
ZJS
92
93 <para>If the administrator wants to disable a configuration file
94 supplied by the vendor, the recommended way is to place a symlink
95 to <filename>/dev/null</filename> in
96 <filename>/etc/tmpfiles.d/</filename> bearing the same filename.
97 </para>
8165be2e
ZJS
98 </refsect1>
99
100 <refsect1>
101 <title>Configuration File Format</title>
302fbdf2
ZJS
102
103 <para>The configuration format is one line per path containing
104 type, path, mode, ownership, age, and argument fields:</para>
105
106 <programlisting>#Type Path Mode UID GID Age Argument
ed7fd549
ZJS
107d /run/user 0755 root root 10d -
108L /tmp/foobar - - - - /dev/null</programlisting>
302fbdf2 109
657cf7f4 110 <para>Fields may be enclosed within quotes and contain C-style escapes.</para>
111
302fbdf2
ZJS
112 <refsect2>
113 <title>Type</title>
114
115 <para>The type consists of a single letter and optionally an
6d7b5433 116 exclamation mark and/or minus sign.</para>
302fbdf2
ZJS
117
118 <para>The following line types are understood:</para>
119
120 <variablelist>
121 <varlistentry>
122 <term><varname>f</varname></term>
49e87292
LP
123 <listitem><para>Create a file if it does not exist yet. If the argument parameter is given and the file did
124 not exist yet, it will be written to the file. Does not follow symlinks.</para></listitem>
302fbdf2
ZJS
125 </varlistentry>
126
127 <varlistentry>
128 <term><varname>F</varname></term>
129 <listitem><para>Create or truncate a file. If the argument
6a9171d2 130 parameter is given, it will be written to the file. Does not follow symlinks.</para>
302fbdf2
ZJS
131 </listitem>
132 </varlistentry>
133
134 <varlistentry>
135 <term><varname>w</varname></term>
136 <listitem><para>Write the argument parameter to a file, if
137 the file exists. Lines of this type accept shell-style
138 globs in place of normal path names. The argument parameter
139 will be written without a trailing newline. C-style
6a9171d2
LP
140 backslash escapes are interpreted. Follows
141 symlinks.</para></listitem>
302fbdf2
ZJS
142 </varlistentry>
143
144 <varlistentry>
145 <term><varname>d</varname></term>
4b743d67
ZJS
146 <listitem><para>Create a directory. The mode and ownership will be adjusted if
147 specified and the directory already exists. Contents of this directory are subject
ed7fd549 148 to time based cleanup if the age argument is specified.</para></listitem>
302fbdf2
ZJS
149 </varlistentry>
150
151 <varlistentry>
152 <term><varname>D</varname></term>
4b743d67
ZJS
153 <listitem><para>Similar to <varname>d</varname>, but in addition the contents
154 of the directory will be removed when <option>--remove</option> is used.
155 </para></listitem>
156 </varlistentry>
df8dee85
ZJS
157
158 <varlistentry>
159 <term><varname>e</varname></term>
ed7fd549
ZJS
160 <listitem><para>Similar to <varname>d</varname>, but the directory will not be created if
161 it does not exist. Lines of this type accept shell-style globs in place of normal path
162 names. For this entry to be useful, at least one of the mode, uid, gid, or age arguments
163 must be specified, since otherwise this entry has no effect. If the age argument is
164 <literal>0</literal>, contents of the directory will be unconditionally deleted every time
165 <command>systemd-tmpfiles --clean</command> is run. This can be useful when combined with
166 <varname>!</varname>, see the examples.</para></listitem>
302fbdf2
ZJS
167 </varlistentry>
168
169 <varlistentry>
170 <term><varname>v</varname></term>
171 <listitem><para>Create a subvolume if the path does not
2904e949
LP
172 exist yet, the file system supports subvolumes (btrfs), and
173 the system itself is installed into a subvolume
174 (specifically: the root directory <filename>/</filename> is
175 itself a subvolume). Otherwise, create a normal directory, in
176 the same way as <varname>d</varname>. A subvolume created
177 with this line type is not assigned to any higher-level
178 quota group. For that, use <varname>q</varname> or
179 <varname>Q</varname>, which allow creating simple quota
180 group hierarchies, see below.</para></listitem>
5fb13eb5
LP
181 </varlistentry>
182
183 <varlistentry>
184 <term><varname>q</varname></term>
f17a8d61
FB
185 <listitem><para>Similar to <varname>v</varname>. However, makes sure that the subvolume will be assigned to
186 the same higher-level quota groups as the subvolume it has been created in. This ensures that higher-level
187 limits and accounting applied to the parent subvolume also include the specified subvolume. On non-btrfs file
188 systems, this line type is identical to <varname>d</varname>.</para>
189
190 <para>If the subvolume already exists, no change to the quota hierarchy is made, regardless of whether the
191 subvolume is already attached to a quota group or not. Also see <varname>Q</varname> below. See <citerefentry
192 project='die-net'><refentrytitle>btrfs-qgroup</refentrytitle><manvolnum>8</manvolnum></citerefentry> for
193 details about the btrfs quota group concept.</para></listitem>
5fb13eb5
LP
194 </varlistentry>
195
196 <varlistentry>
197 <term><varname>Q</varname></term>
f17a8d61
FB
198 <listitem><para>Similar to <varname>q</varname>. However, instead of copying the higher-level quota group
199 assignments from the parent as-is, the lowest quota group of the parent subvolume is determined that is not
200 the leaf quota group. Then, an "intermediary" quota group is inserted that is one level below this level, and
201 shares the same ID part as the specified subvolume. If no higher-level quota group exists for the parent
202 subvolume, a new quota group at level 255 sharing the same ID as the specified subvolume is inserted
203 instead. This new intermediary quota group is then assigned to the parent subvolume's higher-level quota
204 groups, and the specified subvolume's leaf quota group is assigned to it.</para>
205
206 <para>Effectively, this has a similar effect as <varname>q</varname>, however introduces a new higher-level
207 quota group for the specified subvolume that may be used to enforce limits and accounting to the specified
208 subvolume and children subvolume created within it. Thus, by creating subvolumes only via
209 <varname>q</varname> and <varname>Q</varname>, a concept of "subtree quotas" is implemented. Each subvolume
210 for which <varname>Q</varname> is set will get a "subtree" quota group created, and all child subvolumes
211 created within it will be assigned to it. Each subvolume for which <varname>q</varname> is set will not get
212 such a "subtree" quota group, but it is ensured that they are added to the same "subtree" quota group as
213 their immediate parents.</para>
214
215 <para>It is recommended to use <varname>Q</varname> for subvolumes that typically contain further subvolumes,
216 and where it is desirable to have accounting and quota limits on all child subvolumes together. Examples for
217 <varname>Q</varname> are typically <filename>/home</filename> or <filename>/var/lib/machines</filename>. In
218 contrast, <varname>q</varname> should be used for subvolumes that either usually do not include further
219 subvolumes or where no accounting and quota limits are needed that apply to all child subvolumes
220 together. Examples for <varname>q</varname> are typically <filename>/var</filename> or
221 <filename>/var/tmp</filename>. </para>
222
223 <para>As with <varname>q</varname>, <varname>Q</varname> has no effect on the quota group hierarchy if the
224 subvolume already exists, regardless of whether the subvolume already belong to a quota group or
225 not.</para></listitem>
302fbdf2
ZJS
226 </varlistentry>
227
228 <varlistentry>
229 <term><varname>p</varname></term>
230 <term><varname>p+</varname></term>
231 <listitem><para>Create a named pipe (FIFO) if it does not
232 exist yet. If suffixed with <varname>+</varname> and a file
233 already exists where the pipe is to be created, it will be
234 removed and be replaced by the pipe.</para></listitem>
235 </varlistentry>
236
237 <varlistentry>
238 <term><varname>L</varname></term>
239 <term><varname>L+</varname></term>
240 <listitem><para>Create a symlink if it does not exist
b3f5897f
WD
241 yet. If suffixed with <varname>+</varname> and a file or
242 directory already exists where the symlink is to be created,
243 it will be removed and be replaced by the symlink. If the
244 argument is omitted, symlinks to files with the same name
245 residing in the directory
246 <filename>/usr/share/factory/</filename> are created. Note
247 that permissions and ownership on symlinks are ignored.
248 </para></listitem>
302fbdf2
ZJS
249 </varlistentry>
250
251 <varlistentry>
252 <term><varname>c</varname></term>
253 <term><varname>c+</varname></term>
254 <listitem><para>Create a character device node if it does
255 not exist yet. If suffixed with <varname>+</varname> and a
256 file already exists where the device node is to be created,
257 it will be removed and be replaced by the device node. It is
258 recommended to suffix this entry with an exclamation mark to
259 only create static device nodes at boot, as udev will not
260 manage static device nodes that are created at runtime.
261 </para></listitem>
262 </varlistentry>
263
264 <varlistentry>
265 <term><varname>b</varname></term>
266 <term><varname>b+</varname></term>
267 <listitem><para>Create a block device node if it does not
268 exist yet. If suffixed with <varname>+</varname> and a file
269 already exists where the device node is to be created, it
270 will be removed and be replaced by the device node. It is
271 recommended to suffix this entry with an exclamation mark to
272 only create static device nodes at boot, as udev will not
273 manage static device nodes that are created at runtime.
274 </para></listitem>
275 </varlistentry>
276
277 <varlistentry>
278 <term><varname>C</varname></term>
279 <listitem><para>Recursively copy a file or directory, if the
280 destination files or directories do not exist yet. Note that
281 this command will not descend into subdirectories if the
282 destination directory already exists. Instead, the entire
283 copy operation is skipped. If the argument is omitted, files
284 from the source directory
285 <filename>/usr/share/factory/</filename> with the same name
6a9171d2 286 are copied. Does not follow symlinks.</para></listitem>
302fbdf2
ZJS
287 </varlistentry>
288
289 <varlistentry>
290 <term><varname>x</varname></term>
291 <listitem><para>Ignore a path during cleaning. Use this type
292 to exclude paths from clean-up as controlled with the Age
293 parameter. Note that lines of this type do not influence the
294 effect of <varname>r</varname> or <varname>R</varname>
50d9e46d 295 lines. Lines of this type accept shell-style globs in place
302fbdf2
ZJS
296 of normal path names. </para></listitem>
297 </varlistentry>
298
299 <varlistentry>
300 <term><varname>X</varname></term>
301 <listitem><para>Ignore a path during cleaning. Use this type
302 to exclude paths from clean-up as controlled with the Age
303 parameter. Unlike <varname>x</varname>, this parameter will
304 not exclude the content if path is a directory, but only
305 directory itself. Note that lines of this type do not
306 influence the effect of <varname>r</varname> or
50d9e46d 307 <varname>R</varname> lines. Lines of this type accept
302fbdf2
ZJS
308 shell-style globs in place of normal path names.
309 </para></listitem>
310 </varlistentry>
311
312 <varlistentry>
313 <term><varname>r</varname></term>
314 <listitem><para>Remove a file or directory if it exists.
315 This may not be used to remove non-empty directories, use
316 <varname>R</varname> for that. Lines of this type accept
317 shell-style globs in place of normal path
6a9171d2 318 names. Does not follow symlinks.</para></listitem>
302fbdf2
ZJS
319 </varlistentry>
320
321 <varlistentry>
322 <term><varname>R</varname></term>
323 <listitem><para>Recursively remove a path and all its
324 subdirectories (if it is a directory). Lines of this type
325 accept shell-style globs in place of normal path
6a9171d2 326 names. Does not follow symlinks.</para></listitem>
302fbdf2
ZJS
327 </varlistentry>
328
329 <varlistentry>
330 <term><varname>z</varname></term>
331 <listitem><para>Adjust the access mode, group and user, and
332 restore the SELinux security context of a file or directory,
333 if it exists. Lines of this type accept shell-style globs in
6a9171d2 334 place of normal path names. Does not follow symlinks.</para></listitem>
302fbdf2
ZJS
335 </varlistentry>
336
337 <varlistentry>
338 <term><varname>Z</varname></term>
339 <listitem><para>Recursively set the access mode, group and
340 user, and restore the SELinux security context of a file or
341 directory if it exists, as well as of its subdirectories and
342 the files contained therein (if applicable). Lines of this
6a9171d2
LP
343 type accept shell-style globs in place of normal path
344 names. Does not follow symlinks. </para></listitem>
302fbdf2
ZJS
345 </varlistentry>
346
347 <varlistentry>
348 <term><varname>t</varname></term>
b705ab6a
ZJS
349 <listitem><para>Set extended attributes. Lines of this type
350 accept shell-style globs in place of normal path names.
6a9171d2
LP
351 This can be useful for setting SMACK labels. Does not follow
352 symlinks.</para></listitem>
b705ab6a
ZJS
353 </varlistentry>
354
355 <varlistentry>
356 <term><varname>T</varname></term>
357 <listitem><para>Recursively set extended attributes. Lines
358 of this type accept shell-style globs in place of normal
6a9171d2
LP
359 path names. This can be useful for setting SMACK
360 labels. Does not follow symlinks. </para></listitem>
302fbdf2 361 </varlistentry>
f8eeeaf9 362
fa3f5fd2
GB
363 <varlistentry>
364 <term><varname>h</varname></term>
365 <listitem><para>Set file/directory attributes. Lines of this type
366 accept shell-style globs in place of normal path names.</para>
367
1ae705fb
LP
368 <para>The format of the argument field is
369 <varname>[+-=][aAcCdDeijsStTu] </varname>. The prefix
370 <varname>+</varname> (the default one) causes the
fa3f5fd2 371 attribute(s) to be added; <varname>-</varname> causes the
1ae705fb 372 attribute(s) to be removed; <varname>=</varname> causes the
a8eaaee7 373 attributes to be set exactly as the following letters. The
1ae705fb 374 letters <literal>aAcCdDeijsStTu</literal> select the new
fa3f5fd2 375 attributes for the files, see
c30c611c 376 <citerefentry project='man-pages'><refentrytitle>chattr</refentrytitle>
fa3f5fd2
GB
377 <manvolnum>1</manvolnum></citerefentry> for further information.
378 </para>
1ae705fb
LP
379 <para>Passing only <varname>=</varname> as argument resets
380 all the file attributes listed above. It has to be pointed
b938cb90 381 out that the <varname>=</varname> prefix limits itself to
1ae705fb
LP
382 the attributes corresponding to the letters listed here. All
383 other attributes will be left untouched. Does not follow
384 symlinks.</para>
fa3f5fd2
GB
385 </listitem>
386 </varlistentry>
387
388 <varlistentry>
389 <term><varname>H</varname></term>
390 <listitem><para>Recursively set file/directory attributes. Lines
391 of this type accept shell-style globs in place of normal
6a9171d2 392 path names. Does not follow symlinks.
fa3f5fd2
GB
393 </para></listitem>
394 </varlistentry>
395
f8eeeaf9
ZJS
396 <varlistentry>
397 <term><varname>a</varname></term>
50d9e46d
ZJS
398 <term><varname>a+</varname></term>
399 <listitem><para>Set POSIX ACLs (access control lists). If
a8eaaee7 400 suffixed with <varname>+</varname>, the specified entries will
dd4105b0
ZJS
401 be added to the existing set.
402 <command>systemd-tmpfiles</command> will automatically add
403 the required base entries for user and group based on the
404 access mode of the file, unless base entries already exist
7f3fdb7f 405 or are explicitly specified. The mask will be added if not
dd4105b0
ZJS
406 specified explicitly or already present. Lines of this type
407 accept shell-style globs in place of normal path names. This
408 can be useful for allowing additional access to certain
6a9171d2 409 files. Does not follow symlinks.</para></listitem>
b705ab6a
ZJS
410 </varlistentry>
411
412 <varlistentry>
413 <term><varname>A</varname></term>
50d9e46d
ZJS
414 <term><varname>A+</varname></term>
415 <listitem><para>Same as <varname>a</varname> and
6a9171d2
LP
416 <varname>a+</varname>, but recursive. Does not follow
417 symlinks.</para></listitem>
f8eeeaf9 418 </varlistentry>
302fbdf2
ZJS
419 </variablelist>
420
421 <para>If the exclamation mark is used, this line is only safe of
422 execute during boot, and can break a running system. Lines
423 without the exclamation mark are presumed to be safe to execute
424 at any time, e.g. on package upgrades.
425 <command>systemd-tmpfiles</command> will execute line with an
426 exclamation mark only if option <option>--boot</option> is
427 given.</para>
428
429 <para>For example:
430 <programlisting># Make sure these are created by default so that nobody else can
9b9c30ec 431d /tmp/.X11-unix 1777 root root 10d
302fbdf2 432
9b9c30ec
LP
433# Unlink the X11 lock files
434r! /tmp/.X[0-9]*-lock</programlisting>
302fbdf2
ZJS
435 The second line in contrast to the first one would break a
436 running system, and will only be executed with
437 <option>--boot</option>.</para>
7fa10748 438
6d7b5433
WD
439 <para>If the minus sign is used, this line failing to run
440 successfully during create (and only create) will not cause
441 the execution of <command>systemd-tmpfiles</command> to return
442 an error.</para>
443
444 <para>For example:
445 <programlisting># Modify sysfs but don't fail if we are in a container with a read-only /proc
446w- /proc/sys/vm/swappiness - - - - 10</programlisting></para>
447
7fa10748
LP
448 <para>Note that for all line types that result in creation of any kind of file node
449 (i.e. <varname>f</varname>/<varname>F</varname>,
450 <varname>d</varname>/<varname>D</varname>/<varname>v</varname>/<varname>q</varname>/<varname>Q</varname>,
451 <varname>p</varname>, <varname>L</varname>, <varname>c</varname>/<varname>b</varname> and <varname>C</varname>)
452 leading directories are implicitly created if needed, owned by root with an access mode of 0755. In order to
453 create them with different modes or ownership make sure to add appropriate <varname>d</varname> lines.</para>
302fbdf2
ZJS
454 </refsect2>
455
456 <refsect2>
457 <title>Path</title>
458
459 <para>The file system path specification supports simple
2df36d09
ZJS
460 specifier expansion, see below. The path (after expansion) must be
461 absolute.</para>
302fbdf2
ZJS
462 </refsect2>
463
464 <refsect2>
465 <title>Mode</title>
466
467 <para>The file access mode to use when creating this file or
468 directory. If omitted or when set to <literal>-</literal>, the
469 default is used: 0755 for directories, 0644 for all other file
470 objects. For <varname>z</varname>, <varname>Z</varname> lines,
471 if omitted or when set to <literal>-</literal>, the file access
472 mode will not be modified. This parameter is ignored for
473 <varname>x</varname>, <varname>r</varname>,
f8eeeaf9
ZJS
474 <varname>R</varname>, <varname>L</varname>, <varname>t</varname>,
475 and <varname>a</varname> lines.</para>
302fbdf2
ZJS
476
477 <para>Optionally, if prefixed with <literal>~</literal>, the
478 access mode is masked based on the already set access bits for
479 existing file or directories: if the existing file has all
480 executable bits unset, all executable bits are removed from the
481 new access mode, too. Similarly, if all read bits are removed
482 from the old access mode, they will be removed from the new
483 access mode too, and if all write bits are removed, they will be
484 removed from the new access mode too. In addition, the
485 sticky/SUID/SGID bit is removed unless applied to a
486 directory. This functionality is particularly useful in
487 conjunction with <varname>Z</varname>.</para>
488 </refsect2>
489
490 <refsect2>
491 <title>UID, GID</title>
492
8a89c539
YW
493 <para>The user and group to use for this file or directory. This may either be a numeric user/group ID or a user or group
494 name. If omitted or when set to <literal>-</literal>, the user/group ID of the user who invokes <command>systemd-tmpfiles</command> is used.
495 For <varname>z</varname> and <varname>Z</varname> lines, when omitted or when set to <literal>-</literal>, the file ownership will not be
496 modified. These parameters are ignored for <varname>x</varname>, <varname>r</varname>, <varname>R</varname>, <varname>L</varname>,
497 <varname>t</varname>, and <varname>a</varname> lines.</para>
302fbdf2
ZJS
498 </refsect2>
499
500 <refsect2>
501 <title>Age</title>
502 <para>The date field, when set, is used to decide what files to
503 delete when cleaning. If a file or directory is older than the
504 current time minus the age field, it is deleted. The field
505 format is a series of integers each followed by one of the
a8eaaee7 506 following suffixes for the respective time units:
00c53f42
ZJS
507 <constant>s</constant>,
508 <constant>m</constant> or <constant>min</constant>,
509 <constant>h</constant>,
510 <constant>d</constant>,
511 <constant>w</constant>,
a8eaaee7 512 <constant>ms</constant>, and
00c53f42 513 <constant>us</constant>,
a8eaaee7
JE
514 meaning seconds, minutes, hours, days, weeks,
515 milliseconds, and microseconds, respectively. Full names of the time units can
00c53f42
ZJS
516 be used too.
517 </para>
302fbdf2
ZJS
518
519 <para>If multiple integers and units are specified, the time
00c53f42
ZJS
520 values are summed. If an integer is given without a unit,
521 <constant>s</constant> is assumed.
302fbdf2
ZJS
522 </para>
523
524 <para>When the age is set to zero, the files are cleaned
525 unconditionally.</para>
526
5fb13eb5 527 <para>The age field only applies to lines starting with
df8dee85 528 <varname>d</varname>, <varname>D</varname>, <varname>e</varname>,
5fb13eb5
LP
529 <varname>v</varname>, <varname>q</varname>,
530 <varname>Q</varname>, <varname>C</varname>, <varname>x</varname>
531 and <varname>X</varname>. If omitted or set to
532 <literal>-</literal>, no automatic clean-up is done.</para>
302fbdf2
ZJS
533
534 <para>If the age field starts with a tilde character
535 <literal>~</literal>, the clean-up is only applied to files and
536 directories one level inside the directory specified, but not
537 the files and directories immediately inside it.</para>
662b3e58
LW
538
539 <para>The age of a file system entry is determined from its last
540 modification timestamp (mtime), its last access timestamp (atime),
541 and (except for directories) its last status change timestamp
542 (ctime). Any of these three (or two) values will prevent cleanup
543 if it is more recent than the current time minus the age
544 field.</para>
302fbdf2
ZJS
545 </refsect2>
546
547 <refsect2>
548 <title>Argument</title>
549
49e87292
LP
550 <para>For <varname>L</varname> lines determines the destination path of the symlink. For <varname>c</varname> and
551 <varname>b</varname>, determines the major/minor of the device node, with major and minor formatted as integers,
552 separated by <literal>:</literal>, e.g. <literal>1:3</literal>. For <varname>f</varname>, <varname>F</varname>,
553 and <varname>w</varname>, the argument may be used to specify a short string that is written to the file,
554 suffixed by a newline. For <varname>C</varname>, specifies the source file or directory. For <varname>t</varname>
555 and <varname>T</varname>, determines extended attributes to be set. For <varname>a</varname> and
556 <varname>A</varname>, determines ACL attributes to be set. For <varname>h</varname> and <varname>H</varname>,
557 determines the file attributes to set. Ignored for all other lines.</para>
2df36d09
ZJS
558
559 <para>This field can contain specifiers, see below.</para>
302fbdf2 560 </refsect2>
2df36d09 561 </refsect1>
302fbdf2 562
2df36d09
ZJS
563 <refsect1>
564 <title>Specifiers</title>
565
566 <para>Specifiers can be used in the "path" and "argument" fields.
751223fe 567 An unknown or unresolvable specifier is treated as invalid configuration.
2df36d09
ZJS
568 The following expansions are understood:</para>
569 <table>
570 <title>Specifiers available</title>
571 <tgroup cols='3' align='left' colsep='1' rowsep='1'>
572 <colspec colname="spec" />
573 <colspec colname="mean" />
574 <colspec colname="detail" />
575 <thead>
576 <row>
577 <entry>Specifier</entry>
578 <entry>Meaning</entry>
579 <entry>Details</entry>
580 </row>
581 </thead>
582 <tbody>
2df36d09
ZJS
583 <row>
584 <entry><literal>%b</literal></entry>
585 <entry>Boot ID</entry>
586 <entry>The boot ID of the running system, formatted as string. See <citerefentry><refentrytitle>random</refentrytitle><manvolnum>4</manvolnum></citerefentry> for more information.</entry>
587 </row>
709f4c47
LP
588 <row>
589 <entry><literal>%C</literal></entry>
590 <entry>System or user cache directory</entry>
591 <entry>In <option>--user</option> mode, this is the same as <varname>$XDG_CACHE_HOME</varname>, and <filename>/var/cache</filename> otherwise.</entry>
592 </row>
593 <row>
594 <entry><literal>%h</literal></entry>
595 <entry>User home directory</entry>
052c59c3 596 <entry>This is the home directory of the user running the command. In case of the system instance this resolves to <literal>/root</literal>.</entry>
709f4c47 597 </row>
2df36d09
ZJS
598 <row>
599 <entry><literal>%H</literal></entry>
600 <entry>Host name</entry>
601 <entry>The hostname of the running system.</entry>
602 </row>
603 <row>
709f4c47
LP
604 <entry><literal>%L</literal></entry>
605 <entry>System or user log directory</entry>
606 <entry>In <option>--user</option> mode, this is the same as <varname>$XDG_CONFIG_HOME</varname> with <filename noindex='true'>/log</filename> appended, and <filename>/var/log</filename> otherwise.</entry>
ca23eeb5
TW
607 </row>
608 <row>
709f4c47
LP
609 <entry><literal>%m</literal></entry>
610 <entry>Machine ID</entry>
611 <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>
ca23eeb5
TW
612 </row>
613 <row>
709f4c47
LP
614 <entry><literal>%S</literal></entry>
615 <entry>System or user state directory</entry>
616 <entry>In <option>--user</option> mode, this is the same as <varname>$XDG_CONFIG_HOME</varname>, and <filename>/var/lib</filename> otherwise.</entry>
ca23eeb5 617 </row>
5a8575ef
ZJS
618 <row>
619 <entry><literal>%t</literal></entry>
620 <entry>System or user runtime directory</entry>
8252eb18 621 <entry>In <option>--user</option> mode, this is the same <varname>$XDG_RUNTIME_DIR</varname>, and <filename>/run</filename> otherwise.</entry>
5a8575ef 622 </row>
b294e594
LP
623 <row>
624 <entry><literal>%T</literal></entry>
625 <entry>Directory for temporary files</entry>
626 <entry>This is either <filename>/tmp</filename> or the path <literal>$TMPDIR</literal>, <literal>$TEMP</literal> or <literal>$TMP</literal> are set to.</entry>
627 </row>
b75f0c69
DC
628 <row>
629 <entry><literal>%g</literal></entry>
630 <entry>User group</entry>
631 <entry>This is the name of the group running the command. In case of the system instance this resolves to <literal>root</literal>.</entry>
632 </row>
633 <row>
634 <entry><literal>%G</literal></entry>
635 <entry>User GID</entry>
636 <entry>This is the numeric GID of the group running the command. In case of the system instance this resolves to <constant>0</constant>.</entry>
637 </row>
5a8575ef 638 <row>
709f4c47
LP
639 <entry><literal>%u</literal></entry>
640 <entry>User name</entry>
052c59c3 641 <entry>This is the name of the user running the command. In case of the system instance this resolves to <literal>root</literal>.</entry>
5a8575ef
ZJS
642 </row>
643 <row>
709f4c47
LP
644 <entry><literal>%U</literal></entry>
645 <entry>User UID</entry>
052c59c3 646 <entry>This is the numeric UID of the user running the command. In case of the system instance this resolves to <constant>0</constant>.</entry>
5a8575ef
ZJS
647 </row>
648 <row>
709f4c47
LP
649 <entry><literal>%v</literal></entry>
650 <entry>Kernel release</entry>
651 <entry>Identical to <command>uname -r</command> output.</entry>
5a8575ef 652 </row>
b294e594
LP
653 <row>
654 <entry><literal>%V</literal></entry>
655 <entry>Directory for larger and persistent temporary files</entry>
656 <entry>This is either <filename>/var/tmp</filename> or the path <literal>$TMPDIR</literal>, <literal>$TEMP</literal> or <literal>$TMP</literal> are set to.</entry>
657 </row>
2df36d09
ZJS
658 <row>
659 <entry><literal>%%</literal></entry>
5a8575ef 660 <entry>Escaped <literal>%</literal></entry>
2df36d09
ZJS
661 <entry>Single percent sign.</entry>
662 </row>
663 </tbody>
664 </tgroup>
665 </table>
302fbdf2
ZJS
666 </refsect1>
667
668 <refsect1>
4b743d67 669 <title>Examples</title>
302fbdf2 670 <example>
4b743d67
ZJS
671 <title>Create directories with specific mode and ownership</title>
672 <para>
0a07667d 673 <citerefentry project='die-net'><refentrytitle>screen</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
4b743d67
ZJS
674 needs two directories created at boot with specific modes and ownership:</para>
675
676 <programlisting># /usr/lib/tmpfiles.d/screen.conf
677d /run/screens 1777 root screen 10d
678d /run/uscreens 0755 root screen 10d12h
679</programlisting>
680
681 <para>Contents of <filename>/run/screens</filename> and /run/uscreens will
1655cdee 682 be cleaned up after 10 and 10½ days, respectively.</para>
4b743d67 683 </example>
302fbdf2 684
4b743d67
ZJS
685 <example>
686 <title>Create a directory with a SMACK attribute</title>
687 <programlisting>D /run/cups - - - -
688t /run/cups - - - - security.SMACK64=printing user.attr-with-spaces="foo bar"
689 </programlisting>
690
b17649ee 691 <para>The directory will be owned by root and have default mode. Its contents are
4b743d67
ZJS
692 not subject to time based cleanup, but will be obliterated when
693 <command>systemd-tmpfiles --remove</command> runs.</para>
302fbdf2 694 </example>
4b743d67 695
302fbdf2 696 <example>
4b743d67
ZJS
697 <title>Create a directory and prevent its contents from cleanup</title>
698 <para>
0a07667d 699 <citerefentry project='die-net'><refentrytitle>abrt</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
4b743d67
ZJS
700 needs a directory created at boot with specific mode and ownership and its content
701 should be preserved from the automatic cleanup applied to the contents of
702 <filename>/var/tmp</filename>:</para>
703
704 <programlisting># /usr/lib/tmpfiles.d/tmp.conf
705d /var/tmp 1777 root root 30d
706</programlisting>
707
708 <programlisting># /usr/lib/tmpfiles.d/abrt.conf
709d /var/tmp/abrt 0755 abrt abrt -
df8dee85
ZJS
710</programlisting>
711 </example>
712
713 <example>
714 <title>Apply clean up during boot and based on time</title>
715
716 <programlisting># /usr/lib/tmpfiles.d/dnf.conf
717r! /var/cache/dnf/*/*/download_lock.pid
718r! /var/cache/dnf/*/*/metadata_lock.pid
719r! /var/lib/dnf/rpmdb_lock.pid
e80f1a79 720e /var/cache/dnf/ - - - 30d
4b743d67 721</programlisting>
302fbdf2 722
df8dee85 723 <para>The lock files will be removed during boot. Any files and directories in
e80f1a79 724 <filename>/var/cache/dnf/</filename> will be removed after they have not been
df8dee85 725 accessed in 30 days.</para>
302fbdf2 726 </example>
ed7fd549
ZJS
727
728 <example>
b719b26c 729 <title>Empty the contents of a cache directory on boot</title>
ed7fd549
ZJS
730
731 <programlisting># /usr/lib/tmpfiles.d/krb5rcache.conf
732e! /var/cache/krb5rcache - - - 0
733</programlisting>
734
735 <para>Any files and subdirectories in <filename>/var/cache/krb5rcache/</filename>
736 will be removed on boot. The directory will not be created.
737 </para>
738 </example>
302fbdf2
ZJS
739 </refsect1>
740
741 <refsect1>
742 <title>See Also</title>
743 <para>
744 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
745 <citerefentry><refentrytitle>systemd-tmpfiles</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
746 <citerefentry><refentrytitle>systemd-delta</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
f8eeeaf9
ZJS
747 <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
748 <citerefentry project='man-pages'><refentrytitle>attr</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
749 <citerefentry project='man-pages'><refentrytitle>getfattr</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
750 <citerefentry project='man-pages'><refentrytitle>setfattr</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
751 <citerefentry project='man-pages'><refentrytitle>setfacl</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
fa3f5fd2 752 <citerefentry project='man-pages'><refentrytitle>getfacl</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
5fb13eb5
LP
753 <citerefentry project='man-pages'><refentrytitle>chattr</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
754 <citerefentry project='die-net'><refentrytitle>btrfs-subvolume</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
755 <citerefentry project='die-net'><refentrytitle>btrfs-qgroup</refentrytitle><manvolnum>8</manvolnum></citerefentry>
302fbdf2
ZJS
756 </para>
757 </refsect1>
4149f86d
BP
758
759</refentry>