A file dropped in /tmp and found missing with no reboot having happened in between isn’t a mystery: on most modern systemd-based distributions, a dedicated timer periodically cleans /tmp based on file age, independent of any reboot. The belief that /tmp only clears at machine startup hasn’t matched actual behavior for a long time.

The mechanism: a timer, not a reboot

systemd-tmpfiles-clean.timer periodically triggers systemd-tmpfiles --clean, a service that walks configured directories (/tmp and /var/tmp by default) and removes files whose age exceeds a threshold defined in tmpfiles.d configuration files.

# Checks whether cleanup is enabled and
# its next scheduled run
systemctl status systemd-tmpfiles-clean.timer
systemctl list-timers systemd-tmpfiles-clean.timer

Where the age limit is actually configured

The default configuration (/usr/lib/tmpfiles.d/tmp.conf on most distributions) sets a maximum age, often 10 days for /tmp, before a file there becomes eligible for deletion.

# Typical tmp.conf excerpt: d = directory,
# 1777 = permissions with sticky bit, 10d = max age
d /tmp 1777 root root 10d
d /var/tmp 1777 root root 30d

A file stored in /tmp assuming it will only be removed at the next reboot can actually disappear well before that, the moment its age exceeds this threshold, whether the machine has been running continuously for weeks or not.

The fix for a file that genuinely needs to persist

A file or directory needing a longer lifetime than the default shouldn’t work around the rule by editing tmp.conf directly (overwritten on the next package update), but through a dedicated file in /etc/tmpfiles.d/, which cleanly overrides the system configuration without risk of being wiped out.

# /etc/tmpfiles.d/my-app.conf: excludes this specific
# path from automatic cleanup (x = excluded)
x /tmp/my-app/cache

The connection to what we’ve already covered on /tmp

The already-covered sticky bit stops one user from deleting another’s files in /tmp, but does nothing to protect against systemd-tmpfiles’s automatic age-based cleanup, which acts with the service’s own privileges, not those of a regular user subject to normal permission rules.

Takeaway

/tmp isn’t only cleared on reboot: systemd-tmpfiles-clean.timer periodically triggers a deletion based on file age, defaulting to 10 days for /tmp in tmpfiles.d. A file that needs to survive longer requires an exclusion rule in /etc/tmpfiles.d/, never a direct edit to the default system configuration, which gets overwritten on the next update. The sticky bit protects against deletion by other users, but has no effect on this automatic age-based cleanup, an entirely separate mechanism acting with the systemd service’s own privileges.