温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

tmp目录的下的备份文件定期删除

发布时间:2020-08-04 05:12:16 来源:网络 阅读:979 作者:boy461205160 栏目:系统运维

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

#! /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天未访问过的文件。





向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI