Clearing /var/tmp on boot

Pegasus Mc Cleaft ken at
Mon Dec 28 00:22:45 UTC 2009

On Sunday 27 December 2009 23:07:09 Doug Barton wrote:
> Pegasus Mc Cleaft wrote:
> > Hello Current..
> >
> > 	While checking over my system (9-CURRENT AMD64) I was a bit surprised to
> > find tons of old files that were hanging around in my /var/tmp that were
> > never deleted/cleaned out. Most of the offenders were dbus, KDE and PCSCD
> > files. To be honest, I never really checked the /var/tmp directory as I
> > normally use the /tmp for generic stuff (unpacking archives, etc). I was
> > wondering if there should be a startup rc script that cleans this
> > directory as well.

> <from Doug>
> No, there should not. If you look at hier(7) it says this about
> /var/tmp: temporary files that are kept between system reboots

> <from Jilles>
>Like all temporary directories, it is a good idea to clean stale files
>from /var/tmp, but hier(7) explicitly says that /var/tmp is not cleared
>on reboot. In particular, nvi's recovery system puts files in
>/var/tmp/vi.recover/ and assumes they will not be deleted by a reboot
>(see /etc/rc.d/virecover).

Thanks Doug and Jilles, 
	I hadent thought about that and now that I see the man page, I understand. I 
think I will implement what Julles suggested and change the script in my 
/usr/local/etc/rc.d to clear out the files after some period of time so that 
really old (and hopefully useless) items are deleted. 

	In my particular setup, it is rare that I do anything in vi, aside from quick 
config changes and wouldn't be to upset if the system crashed (or got a 
SIGHUP)  in the middle of one and I lost the work in progress. 

	It does make me wonder why some applications would choose to use a temp 
directory with persistence over reboots when you wouldn't think it would be 
necessary (like dbus) but I understand that this is not a FBSD issue. 

Thanks again for you advice,

More information about the freebsd-current mailing list