一、手动清除:
#!/bin/bash
#tomcat logs
find /abc/services/game-8080/logs/ -type f -mtime +7 -exec rm -f '{}' \;
find /abc/services/game-8180/logs/ -type f -mtime +7 -exec rm -f '{}' \;
二、自动脚本:
#配置参数
#清理理日志
c_conf=("/abc/services/service-3180/logs/,local*,10",\
"/abc/services/service-8580/logs/",longsql*,10",\
"/abc/services/service-3180/logs/,longsql*,10",\
"/abc/services/service-3180/logs/,toolbox_bus*,10",\
"/abc/services/statistics-3280/logs/",local*,10",\
)
for i in ${c_conf[@]}
do
tmp=$i
arr=(${tmp//,/ })
echo 删除 ${arr[0]} ${arr[1]} ${arr[2]} 天
find ${arr[0]}${arr[1]} -type f -mtime ${arr[2]} -exec rm -f '{}' \;
done
###写完脚本放到crontab -e 里。