1 <?xml version='
1.0'
?> <!--*-nxml-*-->
2 <!DOCTYPE refentry PUBLIC
"-//OASIS//DTD DocBook XML V4.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
6 SPDX-License-Identifier: LGPL-2.1+
9 <refentry id=
"systemd-tmpfiles"
10 xmlns:
xi=
"http://www.w3.org/2001/XInclude">
13 <title>systemd-tmpfiles
</title>
14 <productname>systemd
</productname>
18 <refentrytitle>systemd-tmpfiles
</refentrytitle>
19 <manvolnum>8</manvolnum>
23 <refname>systemd-tmpfiles
</refname>
24 <refname>systemd-tmpfiles-setup.service
</refname>
25 <refname>systemd-tmpfiles-setup-dev.service
</refname>
26 <refname>systemd-tmpfiles-clean.service
</refname>
27 <refname>systemd-tmpfiles-clean.timer
</refname>
28 <refpurpose>Creates, deletes and cleans up volatile
29 and temporary files and directories
</refpurpose>
34 <command>systemd-tmpfiles
</command>
35 <arg choice=
"opt" rep=
"repeat">OPTIONS
</arg>
36 <arg choice=
"opt" rep=
"repeat"><replaceable>CONFIGFILE
</replaceable></arg>
40 <literallayout><filename>systemd-tmpfiles-setup.service
</filename>
41 <filename>systemd-tmpfiles-setup-dev.service
</filename>
42 <filename>systemd-tmpfiles-clean.service
</filename>
43 <filename>systemd-tmpfiles-clean.timer
</filename></literallayout></para>
46 <literallayout><filename>systemd-tmpfiles-setup.service
</filename>
47 <filename>systemd-tmpfiles-clean.service
</filename>
48 <filename>systemd-tmpfiles-clean.timer
</filename></literallayout></para>
52 <title>Description
</title>
54 <para><command>systemd-tmpfiles
</command> creates, deletes, and
55 cleans up volatile and temporary files and directories, based on
56 the configuration file format and location specified in
57 <citerefentry><refentrytitle>tmpfiles.d
</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
60 <para>If invoked with no arguments, it applies all directives from all configuration
61 files. When invoked with
<option>--replace=
<replaceable>PATH
</replaceable></option>,
62 arguments specified on the command line are used instead of the configuration file
63 <replaceable>PATH
</replaceable>. Otherwise, if one or more absolute filenames are
64 passed on the command line, only the directives in these files are applied. If
65 <literal>-
</literal> is specified instead of a filename, directives are read from
66 standard input. If only the basename of a configuration file is specified, all
67 configuration directories as specified in
68 <citerefentry><refentrytitle>tmpfiles.d
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
69 are searched for a matching file and the file found that has the highest priority is
74 <title>Options
</title>
76 <para>The following options are understood:
</para>
80 <term><option>--create
</option></term>
81 <listitem><para>If this option is passed, all files and
82 directories marked with
94 in the configuration files are created or written to. Files
95 and directories marked with
100 <varname>a
</varname>, and
101 <varname>A
</varname> have their ownership, access mode and
102 security labels set.
</para></listitem>
106 <term><option>--clean
</option></term>
107 <listitem><para>If this option is passed, all files and
108 directories with an age parameter configured will be cleaned
109 up.
</para></listitem>
113 <term><option>--remove
</option></term>
114 <listitem><para>If this option is passed, the contents of
115 directories marked with
<varname>D
</varname> or
116 <varname>R
</varname>, and files or directories themselves
117 marked with
<varname>r
</varname> or
<varname>R
</varname> are
118 removed.
</para></listitem>
122 <term><option>--user
</option></term>
123 <listitem><para>Execute
"user" configuration, i.e.
<filename>tmpfiles.d
</filename>
124 files in user configuration directories.
</para></listitem>
128 <term><option>--boot
</option></term>
129 <listitem><para>Also execute lines with an exclamation mark.
134 <term><option>--prefix=
<replaceable>path
</replaceable></option></term>
135 <listitem><para>Only apply rules with paths that start with
136 the specified prefix. This option can be specified multiple
137 times.
</para></listitem>
140 <term><option>--exclude-prefix=
<replaceable>path
</replaceable></option></term>
141 <listitem><para>Ignore rules with paths that start with the
142 specified prefix. This option can be specified multiple
143 times.
</para></listitem>
147 <term><option>--root=
<replaceable>root
</replaceable></option></term>
148 <listitem><para>Takes a directory path as an argument. All paths will be prefixed with the given alternate
149 <replaceable>root
</replaceable> path, including config search paths.
</para>
151 <para>Note that this option does not alter how the users and groups specified in the configuration files are
152 resolved. With or without this option, users and groups are always resolved according to the host's user and
153 group databases, any such databases stored under the specified root directories are not
154 consulted.
</para></listitem>
158 <term><option>--replace=
<replaceable>PATH
</replaceable></option></term>
159 <listitem><para>When this option is given, one ore more positional arguments
160 must be specified. All configuration files found in the directories listed in
161 <citerefentry><refentrytitle>tmpfiles.d
</refentrytitle><manvolnum>5</manvolnum></citerefentry>
162 will be read, and the configuration given on the command line will be
163 handled instead of and with the same priority as the configuration file
164 <replaceable>PATH
</replaceable>.
</para>
166 <para>This option is intended to be used when package installation scripts
167 are running and files belonging to that package are not yet available on
168 disk, so their contents must be given on the command line, but the admin
169 configuration might already exist and should be given higher priority.
173 <xi:include href=
"standard-options.xml" xpointer=
"cat-config" />
174 <xi:include href=
"standard-options.xml" xpointer=
"no-pager" />
175 <xi:include href=
"standard-options.xml" xpointer=
"help" />
176 <xi:include href=
"standard-options.xml" xpointer=
"version" />
179 <para>It is possible to combine
<option>--create
</option>,
180 <option>--clean
</option>, and
<option>--remove
</option> in one
181 invocation. For example, during boot the following command line is
182 executed to ensure that all temporary and volatile directories are
183 removed and created according to the configuration file:
</para>
185 <programlisting>systemd-tmpfiles --remove --create
</programlisting>
190 <title>Unprivileged --cleanup operation
</title>
192 <para><command>systemd-tmpfiles
</command> tries to avoid changing
193 the access and modification times on the directories it accesses,
194 which requires
<constant>CAP_FOWNER
</constant> privileges. When
195 running as non-root, directories which are checked for files to
196 clean up will have their access time bumped, which might prevent
202 <title>Exit status
</title>
204 <para>On success,
0 is returned. If the configuration was syntactically invalid (syntax errors,
205 missing arguments, …), so some lines had to be ignored, but no other errors occurred,
206 <constant>65</constant> is returned (
<constant>EX_DATAERR
</constant> from
207 <filename>/usr/include/sysexits.h
</filename>). If the configuration was syntactically valid, but
208 could not be executed (lack of permissions, creation of files in missing directories, invalid
209 contents when writing to
<filename>/sys/
</filename> values, …),
<constant>73</constant> is
210 returned (
<constant>EX_CANTCREAT
</constant> from
<filename>/usr/include/sysexits.h
</filename>).
211 Otherwise,
<constant>1</constant> is returned (
<constant>EXIT_FAILURE
</constant> from
212 <filename>/usr/include/stdlib.h
</filename>).
217 <title>See Also
</title>
219 <citerefentry><refentrytitle>systemd
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
220 <citerefentry><refentrytitle>tmpfiles.d
</refentrytitle><manvolnum>5</manvolnum></citerefentry>