Updated: 28 September 2026 · Applies to: systemd-tmpfiles on AlmaLinux and Rocky Linux 9 and 10, RHEL 9 and 10, Ubuntu 24.04 and 26.04, Debian 13

If files you left in /tmp or /var/tmp disappear, the system cleaned them up on purpose. These folders are for temporary files, and old ones are removed automatically so they cannot fill the disk. On CentOS 6 a cron job called tmpwatch did this; since CentOS 7, and on all current distributions, the systemd-tmpfiles-clean.timer does it, following rules in the tmpfiles.d folders.

What gets deleted, and when

  • AlmaLinux, Rocky Linux, RHEL 9 and 10: files in /tmp not used for 10 days, and in /var/tmp not used for 30 days.
  • Debian 13: the same ages, and /tmp is now a RAM disk (tmpfs), so it is also emptied at every reboot.
  • Ubuntu 24.04: /tmp is emptied at boot, and files not used for 30 days are removed while the system runs.

"Not used" means that the access, modification and change times are all older than the age. The cleanup runs about 15 minutes after boot and then once a day.

See the rules on your server

cat /usr/lib/tmpfiles.d/tmp.conf
systemctl list-timers systemd-tmpfiles-clean.timer

A line such as q /tmp 1777 root root 10d means: create /tmp with these permissions, and clean entries older than 10 days.

Keep files longer, or keep some files

Never edit the file in /usr/lib/tmpfiles.d/; package updates overwrite it. Put your own rules in /etc/tmpfiles.d/, where a file with the same name replaces the system one.

  1. To change the age for /tmp to 30 days, create /etc/tmpfiles.d/tmp.conf with a copy of the system file and change the age, for example:
    q /tmp 1777 root root 30d
    q /var/tmp 1777 root root 30d
  2. To protect one folder from cleanup, create /etc/tmpfiles.d/keep-myapp.conf:
    x /tmp/myapp
    x excludes the path and everything in it. Use X to exclude only the folder but not its contents.
  3. Test your rules without waiting a day:
    systemd-tmpfiles --clean

Better: do not keep important files in /tmp

Files that must survive belong elsewhere: application data under /var/lib/yourapp, caches under /var/cache/yourapp, and user files in home folders. A systemd service can get its own private, cleaned-up temporary folder with PrivateTmp=yes, which many packaged services already use. Their files then live under /tmp/systemd-private-*, not directly in /tmp.

Common problems

  • A running program loses its socket or lock file in /tmp: the file was idle longer than the age. Exclude its folder with an x rule, or move it to /run.
  • /tmp is full on Debian 13: it is in RAM and its size is limited. Large temporary files belong in /var/tmp.

Official documentation: tmpfiles.d and systemd-tmpfiles.

Ucartz services for this topic

Was this answer helpful? 0 Users Found This Useful (0 Votes)