Skip to content

Instantly share code, notes, and snippets.

@mihir-kumar-thakur
Last active July 22, 2019 07:30
Show Gist options
  • Save mihir-kumar-thakur/2c60f2e8ddeb659fd3900de49de8a7d3 to your computer and use it in GitHub Desktop.
Save mihir-kumar-thakur/2c60f2e8ddeb659fd3900de49de8a7d3 to your computer and use it in GitHub Desktop.
Clean Ubuntu Temp File - Setting

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:

#/etc/tmpfiles.d/tmp.conf

d /tmp 1777 root root 20d 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.

Also worth noting: you can test your configuration by running the cleaning job manually: systemctl start systemd-tmpfiles-clean

https://askubuntu.com/questions/20783/how-is-the-tmp-directory-cleaned-up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment