2

/var/tmp is not defined in POSIX, but is defined in FHS:

5.15. /var/tmp : Temporary files preserved between system reboots
5.15.1. Purpose
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.

This is a very difficult definition for real life situations. A package does not use /tmp, because the files should not be deleted on reboot for some reason.

If a package fails to cleanup its remains in /tmp the distribution/admin can safely clean at reboot.

When and how should we clean up /var/tmp? What can packages and software developers expect from /var/tmp?

Do we have to clean /var/tmp after n reboots?

(see also What can go wrong if /var/tmp is on a temporary filesystem? and What is the difference between /tmp and /var/tmp?)

8
  • Cleaning up after n reboots violates FHS and introduces an uncertainty to applications as to when their files will not be preserved. Perhaps something based on find /var/tmp/ -mtime +30 will be more consistent.
    – doneal24
    Apr 10, 2022 at 16:30
  • @doneal24 no, this would be a violation of Files and directories located in /var/tmp must not be deleted when the system is booted. And who knows that a reboot is more often than once in 30 days? Apr 10, 2022 at 16:44
  • 1
    Although data stored in /var/tmp is typically deleted in a site-specific manner. I don't see how this question could be answered ... Maybe if a specific package is involved, otherwise it seems pretty clear that there is no general rule. Apr 10, 2022 at 17:41
  • 5
    IMHO the description is wrong. Permanent temporary files makes no sense. It's used for temporary storage of "large" amounts of data. Too many apps never clean after themselves (eg. flatpak). systemd-tmpfiles is suppose to clean it but it doesn't work well. I wipe it on boot regardless, YMMV.
    – CR.
    Apr 10, 2022 at 17:55
  • 1
    Thank you very much for your comments. I take home that the definition is not very useful here and filed a bug for improvement so that it becomes clearer in future FHS bugs.linuxfoundation.org/show_bug.cgi?id=1444 Apr 10, 2022 at 18:46

0

You must log in to answer this question.

Browse other questions tagged .