Example 1. Create directories with specific mode and ownership
screen(1), needs two directories created at boot with specific
modes and ownership:
# /usr/lib/tmpfiles.d/screen.conf
d /run/screens 1777 root screen 10d
d /run/uscreens 0755 root screen 10d12h
Contents of /run/screens and /run/uscreens will be cleaned up
after 10 and 10½ days, respectively.
Example 2. Create a directory with a SMACK attribute
D /run/cups - - - -
t /run/cups - - - - security.SMACK64=printing user.attr-with-spaces="foo bar"
The directory will be owned by root and have default mode. Its
contents are not subject to time based cleanup, but will be
obliterated when systemd-tmpfiles --remove
runs.
Example 3. Create a directory and prevent its contents from
cleanup
abrt
(1), needs a directory created at boot with specific mode and
ownership and its content should be preserved from the automatic
cleanup applied to the contents of /var/tmp:
# /usr/lib/tmpfiles.d/tmp.conf
d /var/tmp 1777 root root 30d
# /usr/lib/tmpfiles.d/abrt.conf
d /var/tmp/abrt 0755 abrt abrt -
Example 4. Apply clean up during boot and based on time
# /usr/lib/tmpfiles.d/dnf.conf
r! /var/cache/dnf/*/*/download_lock.pid
r! /var/cache/dnf/*/*/metadata_lock.pid
r! /var/lib/dnf/rpmdb_lock.pid
e /var/cache/dnf/ - - - 30d
The lock files will be removed during boot. Any files and
directories in /var/cache/dnf/ will be removed after they have
not been accessed in 30 days.
Example 5. Empty the contents of a cache directory on boot
# /usr/lib/tmpfiles.d/krb5rcache.conf
e! /var/cache/krb5rcache - - - 0
Any files and subdirectories in /var/cache/krb5rcache/ will be
removed on boot. The directory will not be created.