linux系统定期清理31天前的应用日志脚本

#!/bin/sh
echo "开始删除额度系统31天前日志" >> /dccapp/cleanlog.log
time=date +%T
echo 该任务执行时间:date +%Y-%m-%d ${time} >> /dccapp/cleanlog.log

#构造查询日志字符串 31天前的时间
beginreg=date -d "31 day ago" +%Y-%m-%d
finalstr=""${beginreg}".log"
echo "删除日志清单列表:" >> /dccapp/cleanlog.log
find /dccapp/ -name "${finalstr}" >> /dccapp/cleanlog.log
#删除31天前天的日志
find /dccapp/SCE3_cz/serviceability_1/log -mtime +31 -name "
.log" -exec rm -rf {} \;
find /dccapp/SCE3_cz/serviceability_2/log -mtime +31 -name "
.log" -exec rm -rf {} \;
find /dccapp/Scene3/serviceability_1/log -mtime +31 -name "
.log" -exec rm -rf {} \;
find /dccapp/Scene3/serviceability_2/log -mtime +31 -name "
.log" -exec rm -rf {} \;
find /dccapp/Scene3/serviceability_3/log -mtime +31 -name "
.log" -exec rm -rf {} \;
find /dccapp/Scene3/serviceability_4/log -mtime +31 -name "
.log*" -exec rm -rf {} \;
echo "----------删除成功!-----------" >> /dccapp/cleanlog.log

#定时任务为 10 0 * /dccapp/cleanlog.sh >/dev/null 2>&1 注意定时任务10 0后面的两个型号没有显示,请注意
#每天凌晨0点10分执行/dccapp/cleanlog.sh文件进行数据清理任务了