Linux有两个公知的临时目录:/tmp与/var/tmp
这两个目录被用户用于存储临时性的文件,亦经常被读写用户存储临时性数据。
两个目录没有本质上的区别,最根本的区别仅仅是系统对其中文件清理的默认时间配置不一致。
/tmp 目录默认清理10天未用的文件,系统重启会清空目录。
/var/tmp 目录默认清理30天未用的文件。
CentOS 6系统在/etc/cron.daily/tmpwatch
[root@db01 ~]# cat /usr/lib/tmpfiles.d/tmp.conf # This file is part of systemd. # # systemd is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. # See tmpfiles.d(5) for details # Clear tmp directories separately, to make them easier to override v /tmp 1777 root root 10d v /var/tmp 1777 root root 30d # Exclude namespace mountpoints created with PrivateTmp=yes x /tmp/systemd-private-%b-* X /tmp/systemd-private-%b-*/tmp x /var/tmp/systemd-private-%b-* X /var/tmp/systemd-private-%b-*/tmp
如果/tmp目录被误删除了也没事,重建就可以了
[root@db01 ~]# mkdir -p /tmp [root@db01 ~]# chmod a+rwx,o+t /tmp [root@db01 ~]# ls -ld /tmp drwxrwxrwt. 9 root root 4096 Jan 13 03:47 /tmp