This is part of the Semicolon&Sons Code Diary - consisting of lessons learned on the job. You're in the unix category.
Last Updated: 2024-11-21
/tmp
is deleted much more frequently - not only between reboots but often
between separate invocations of a program during a single boot
/var/tmp
keeps files across system reboots (e.g. caches in a web-server)
As a result:
/var/tmp
is often mounted on the disk (i.e. not tmpfs
). Therefore slower,
since it writes out to disk more often (wasting resources with transient
workloads)/tmp
is often mounted in RAM or swap (technical term: tmpfs
). In
this case, data is only written to disk when RAM is likely to get full.