How is the /tmp directory cleaned up
永远不要把重要文件放到/tmp
目录下,即使是临时存放也不要,因为只要系统一重启/tmp
目录就会被清空。
曾经在Ubuntu虚拟机上测试OneFeed部署的时候,想记录下部署时涉及到的每个命令方便后来在生产环境部署。
因为涉及到多个Linux user(一个没有sudo权限的Linux user用于跑Rails App,另一个有sudo权限的user用于安装各种软件),
所以就把文件放在了/tmp
目录下。
在差不多部署好的时候,为了能在主机上访问虚拟机上部署的应用,需要配置VirtualBox的Host-only Networks,
配置好后需要重启虚拟机。。。😱
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.