Centos/RHEL/Fedora系統徹底安裝,系統存在清理機制,會定時清理/tmp目錄下文件linux
Centos/RHEL/Fedora系統最小化安裝沒有該機制bash
用到工具:tmpwatchide
yum install tmpwatch -y工具
包含如下文件:spa
/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
pwa
tmpwatch命令的做用就是刪除一段時間內不使用的文件
安裝後會在/etc/cron.daily/目錄下生成一個tmpwatch文件。內容以下:unix
[root@LAMP linuxuser]# ls /etc/cron.daily/
logrotate makewhatis.cron mlocate.cron tmpwatchit
#! /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天未訪問過的文件。
class