#!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 {} \;

 

文件命名为:del_log.sh

 

重新编辑:/etc/crontab

将文件:del_log.sh,以定时任务形式写入到 /etc/crontab 中

 

相关文章:

  • 2021-11-09
  • 2021-08-31
  • 2022-12-23
  • 2022-12-23
  • 2021-12-15
  • 2021-08-13
猜你喜欢
  • 2021-09-23
  • 2022-12-23
  • 2021-06-29
  • 2021-09-17
  • 2021-08-02
  • 2021-10-11
  • 2022-12-23
相关资源
相似解决方案