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
/tmpnot used for 10 days, and in/var/tmpnot used for 30 days. - Debian 13: the same ages, and
/tmpis now a RAM disk (tmpfs), so it is also emptied at every reboot. - Ubuntu 24.04:
/tmpis 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.
- To change the age for
/tmpto 30 days, create/etc/tmpfiles.d/tmp.confwith 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
- To protect one folder from cleanup, create
/etc/tmpfiles.d/keep-myapp.conf:x /tmp/myapp
xexcludes the path and everything in it. UseXto exclude only the folder but not its contents. - 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
xrule, 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
- 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.
- Linux server management: hardening, patching, monitoring and automation for Ubuntu, Debian, RHEL and AlmaLinux.
