码迷,mamicode.com
首页 > 其他好文 > 详细

centos定时删除log文件

时间:2019-12-21 11:35:44      阅读:144      评论:0      收藏:0      [点我收藏+]

标签:文件   www   mdi   arp   logs   cal   time   pre   date   

#!bin/bash
#获取年
time=$(date "+%Y")

#查找并删除7天前的文件
find /opt/applog/travelsky -type f -mtime +7 -exec rm -f {} \;
find /xcx/hislogs/logs -type f -mtime +7 -exec rm -f {} \;

#查找并删除7天前的文件
find /usr/local/proxy-web/logs -type f -mtime +7 -exec rm -f {} \;

查找并删除7天前的文件
find /var/www/html/wxsdairpro/log/ticket  -mtime +7 -exec rm -f {} \;
查找并删除空目录
find /var/www/html/wxsdairpro/log/ticket/$time -exec rmdir -p {} \;
find /var/www/html/wxsdairpro/log/ticket/$time  -mtime +7 -exec rm -f {} \;

find /var/www/html/wxsdairpro/log/order  -mtime +7 -exec rm -f {} \;
find /var/www/html/wxsdairpro/log/order/$time   -exec rmdir -p {} \;
find /var/www/html/wxsdairpro/log/order/$time  -mtime +7 -exec rm -f {} \;

find /var/www/html/wxsdairpro/log/mohe -mtime +7 -exec rm -f {} \;
find /var/www/html/wxsdairpro/log/mohe/$time   -exec rmdir -p {} \;
find /var/www/html/wxsdairpro/log/mohe/$time -mtime +7 -exec rm -f {} \;

find /var/www/html/wxsdairpro/log/checkinsure -mtime +7 -exec rm -f {} \;
find /var/www/html/wxsdairpro/log/checkinsure/$time   -exec rmdir -p {} \;
find /var/www/html/wxsdairpro/log/checkinsure/$time -mtime +7 -exec rm -f {} \;

find /var/www/html/wxsdairpro/log/checkin -mtime +7 -exec rm -f {} \;
find /var/www/html/wxsdairpro/log/checkin/$time   -exec rmdir -p {} \;
find /var/www/html/wxsdairpro/log/checkin/$time -mtime +7 -exec rm -f {} \;

 

centos定时删除log文件

标签:文件   www   mdi   arp   logs   cal   time   pre   date   

原文地址:https://www.cnblogs.com/achengmu/p/12076357.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!