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