I'm unsure what happens to the living host whenever the /tmp
folder is flooded (put to the max storage capacity) - does Linux have some
sort of fail safe to this, or will it, until reboot, leave the files there?
1 Answer
/tmp directory, it is cleared on reboot
If it's tmpfs
(valid for some newer distros), then yes. Otherwise it's not generally cleaned up on reboot or shut down. Old files in it could be cleaned up by a cron/systemd timer task.
An addendum by @telcoM: "On distros using systemd
, you might find systemd-tmpfiles
cleaning the temporary files, triggered by systemd-tmpfiles-clean.timer
and configurable by a tmpfiles.d
directories under /usr/lib/
(distribution's standard config), /etc/
(local customizations) and /run/
(non-persistent configuration). RHEL 7
(and newer?) use this mechanism to auto-clean any files that have not been modified in 30 days from /tmp
."
what happens to the living host whenever the /tmp folder is flooded (put to the max storage capacity)
Nothing much, most Linux utilities/services don't actively write to /tmp. If they do, it's solely application dependent.
does Linux have some sort of fail safe to this, or will it, until reboot, leave the files there?
No failsafe that I'm aware of. It's your responsibility as a user.
-
1On distros using
systemd
, you might findsystemd-tmpfiles
cleaning the temporary files, triggered bysystemd-tmpfiles-clean.timer
and configurable by atmpfiles.d
directories under/usr/lib/
(distribution's standard config),/etc/
(local customizations) and/run/
(non-persistent configuration). RHEL 7 (and newer?) use this mechanism to auto-clean any files that have not been modified in 30 days from/tmp
, and that caused us a bit of a surprise at work. Fortunately we had backups. A lesson to not leave anything important in/tmp
for sure.– telcoMMar 8 at 19:52
/tmp
always gets cleared on reboot is wrong - POSIX recommends "that files and directories located in /tmp be deleted whenever the system is booted" (source), but it's not required, some distros don't.