Updated: 28 September 2026 · Applies to: systemd-tmpfiles (systemd 252 to 259) on AlmaLinux and Rocky Linux 9 and 10, RHEL 9 and 10, Ubuntu 24.04 and 26.04, Debian 13
systemd-tmpfiles creates, cleans and removes temporary files and folders according to simple rule files. It replaced tmpwatch (CentOS 6 and older), and it is what deletes old files from /tmp and /var/tmp. This page explains how it works and how to write your own rules. For the default ages on each distribution, see why files in /tmp get deleted automatically.
When it runs
- At boot,
systemd-tmpfiles-setup.servicecreates the listed folders and, for rules that ask for it, removes old content. systemd-tmpfiles-clean.timerruns the age-based cleanup 15 minutes after boot and then once a day.
systemctl list-timers systemd-tmpfiles-clean.timer
Where the rules are
Rule files ending in .conf are read from /usr/lib/tmpfiles.d/ (packages), /run/tmpfiles.d/ and /etc/tmpfiles.d/ (yours). A file in /etc/tmpfiles.d/ replaces a package file with the same name. Show the merged result with:
systemd-tmpfiles --cat-config | less
Rule format
# Type Path Mode User Group Age d /var/cache/myapp 0750 app app 7d
Common types:
d: create the folder if missing; clean entries older than Age.D: liked, and also empty it at boot.q: liked, and create it as a Btrfs subvolume where possible (used for/tmpand/var/tmp).x: exclude a path (and its contents) from cleaning.X: exclude only the path itself, not its contents.randR: remove a path (R recursively) when run with--remove.
Age accepts values such as 30s, 12h, 10d or 4w. A file is old when its access, modification and change times are all older than the age.
Example: clean an application's cache folder
- Create
/etc/tmpfiles.d/myapp.conf:d /var/cache/myapp 0750 app app 7d
- Create the folder now and test the cleanup:
systemd-tmpfiles --create /etc/tmpfiles.d/myapp.conf systemd-tmpfiles --clean /etc/tmpfiles.d/myapp.conf
From now on, the daily timer deletes files in /var/cache/myapp that were not used for seven days.
Official documentation: tmpfiles.d and systemd-tmpfiles.