How long are files kept in /var/tmp/, and how to use the directory?
I'm always hesitant to use /var/tmp/, because I never quite know exactly how long the files are kept there for, or even what the directory is used for. What determines when a file gets removed from /var/tmp/, and how is the directory intended to be used?
12 Answers
Per the Filesystem hierarchy standard (FHS), files in /var/tmp are to be preserved across reboots.
Per FHS-2.3:
The /var/tmp directory is made available for programs that require temporary files or directories that are preserved between system reboots. Therefore, data stored in /var/tmp is more persistent than data in /tmp.
Files and directories located in /var/tmp must not be deleted when the system is booted. Although data stored in /var/tmp is typically deleted in a site-specific manner, it is recommended that deletions occur at a less frequent interval than /tmp.
I'm not aware of any Linux distributions that automatically clean /var/tmp. IMO, the applications that use /var/www cleanup after themselves in some reasonable manner.
All RHEL-based distros clean /var/tmp of files older than 30 days. I don't know about other distros. Look for a cron entry that invokes tmpwatch. On Fedora/RHEL it is /etc/. It has a line like:
/usr/sbin/tmpwatch "$flags" 30d /var/tmpor
/usr/sbin/tmpwatch 720 /var/tmp(720 hours = 30 days)
2More in general
"Zoraya ter Beek, age 29, just died by assisted suicide in the Netherlands. She was physically healthy, but psychologically depressed. It's an abomination that an entire society would actively facilitate, even encourage, someone ending their own life because they had no hope. Th…"