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.service creates the listed folders and, for rules that ask for it, removes old content.
  • systemd-tmpfiles-clean.timer runs 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: like d, and also empty it at boot.
  • q: like d, and create it as a Btrfs subvolume where possible (used for /tmp and /var/tmp).
  • x: exclude a path (and its contents) from cleaning.
  • X: exclude only the path itself, not its contents.
  • r and R: 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

  1. Create /etc/tmpfiles.d/myapp.conf:
    d /var/cache/myapp 0750 app app 7d
  2. 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.

Related services

KVM VPS hosting

NVMe SSD and full root access, with Free Basic Managed Support.

Unmanaged dedicated servers

full root access and free IPMI KVM, with Free Basic Managed Support.

Managed dedicated servers

our engineers look after the server for you, from $135 a month.

Was this answer helpful?

Still stuck? Open a ticket