How is the /tmp directory cleaned up? Is it automatic? If so, how frequently is it cleaned up?
|
|
||||
|
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 The script does roughly the following: if a file in The default value of |
|||||||||||||||||
|
|
In a
And
So You can change the timer behaviour itself using |
|||
|
|
|
I'm checking this on Ubuntu 16.10. I can certify that editing /etc/default/rcS has no effect at all anymore and the files in tmp are wiped out by reboot no matter what you put in that file. As others mention, tmpreaper is no longer used. I think the right answer is that Ubuntu 16.10 has a new setup. There is a folder /etc/tmpfiles.d, documented in the man page "tmpfiles.d". In that folder, one should place a configuration file to control whether the /tmp is to be erased. This is what I am doing to stop reboots from erasing files in /tmp unless they are 20 days old:
Replace "20d" by "-" if you never want files deleted. This is my best effort, that man page is nearly impenetrable with detail. The advantage of the new setup is that a file cleaner can still run even if the system is not rebooted (as in the case of an always on server). That's a big plus, I think. |
|||||
|
Before 14.04:It is cleaned up every time you reboot. |
|||||||||||||
|
|
While the Changing the The default setting that tells your system to clear The current value of
This setting would allow files to stay in |
|||||||||||||||||
|
|
In Ubuntu 14.04 this is done by |
|||||
|
|
On one of our servers running Ubuntu, we have a script to remove files in /tmp and it runs nightly. The script is:
Just save the contents above to a file chmod 775 the file and create a cron entry to run it. Since this is a web server we don't want to reboot it for obvious reasons. |
|||||||||
|
|
The directory is cleared by default at every boot, because Here you can change the time in the following file:
|
|||||||||||||||||||||
|
protected by Community♦ Feb 11 '15 at 14:09
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?
tmpfs /tmp tmpfs defaults,noatime,mode=1777 0 0in /etc/fstab. – Anonymous Nov 16 '11 at 23:43