Centos/RHEL/Fedora系统完全安装,系统存在清理机制,会定时清理/tmp目录下文件
Centos/RHEL/Fedora系统最小化安装没有该机制
用到工具:tmpwatch
yum install tmpwatch -y
包含以下文件:
/etc/cron.daily/tmpwatch
/usr/bin/tmpwatch
/usr/sbin/tmpwatch
/usr/share/doc/tmpwatch-2.9.16
/usr/share/doc/tmpwatch-2.9.16/COPYING
/usr/share/doc/tmpwatch-2.9.16/ChangeLog
/usr/share/doc/tmpwatch-2.9.16/NEWS
/usr/share/doc/tmpwatch-2.9.16/README
/usr/share/man/man8/tmpwatch.8.gz
tmpwatch命令的作用就是删除一段时间内不使用的文件
安装后会在/etc/cron.daily/目录下生成一个tmpwatch文件。内容如下:
[root@LAMP linuxuser]# ls /etc/cron.daily/
logrotate makewhatis.cron mlocate.cron tmpwatch
1
2
3
4
5
6
7
8
9
10
11
12
|
#! /bin/sh
flags=-umc
/usr/sbin/tmpwatch
"$flags"
-x
/tmp/
.X11-unix -x
/tmp/
.XIM-unix \
-x
/tmp/
.font-unix -x
/tmp/
.ICE-unix -x
/tmp/
.Test-unix \
-X
'/tmp/hsperfdata_*'
-X
'/tmp/.hdb*lock'
-X
'/tmp/.sapstartsrv*.log'
\
-X
'/tmp/pymp-*'
10d
/tmp
/usr/sbin/tmpwatch
"$flags"
30d
/var/tmp
for
d
in
/var/
{cache
/man
,catman}/{
cat
?,X11R6
/cat
?,
local
/cat
?};
do
if
[ -d
"$d"
];
then
/usr/sbin/tmpwatch
"$flags"
-f 30d
"$d"
fi
done
|
从脚本中可看出,tmp目录会删除10天未访问过的文件。
本文转自 boy461205160 51CTO博客,原文链接:http://blog.51cto.com/461205160/1929646