How is the /tmp
directory cleaned up? Is it automatic? If so, how frequently is it cleaned up?
Ubuntu – How is the /tmp directory cleaned up
filesystemtmp
filesystemtmp
How is the /tmp
directory cleaned up? Is it automatic? If so, how frequently is it cleaned up?
Best Answer
Note! This answer is outdated since at least ubuntu 14.04. See other answers for current situation and if they prove correct then upvote them furiously. Also post comment so I can put link here to current correct answer.
For 14.04 see https://askubuntu.com/a/759048/1366
For 16.10 see https://askubuntu.com/a/857154/453746
Old answer from 2011:
The cleaning of
/tmp
is done by the upstart script/etc/init/mounted-tmp.conf
. The script is run by upstart everytime/tmp
is mounted. Practically that means at every boot.The script does roughly the following: if a file in
/tmp
is older than$TMPTIME
days it will be deleted.The default value of
$TMPTIME
is 0, which means every file and directory in/tmp
gets deleted.$TMPTIME
is an environment variable defined in/etc/default/rcS
.