生产环境trace log等日志清理脚本

牧云@^-^@ 提交于 2020-04-03 10:25:24
[root@MPP01 /]#crontab -l
0 2 * * * /root/script/file_cleanup.sh  1>/dev/null 2>&1l
[root@MPP01 /]# more /root/script/file_cleanup.sh 
#!/bin/sh
#loong576
current_date=`date +'%Y-%m-%d'`
cleanup_date=`date +%Y-%m-%d --date="-30 day"`
log_file1=/log/umsservice
log_file2=/opt/AppServer/apache-tomcat-6.0.35/webapps/ums400/data/log
log_file3=/log/playagent
log_file4=/opt/AppServer/apache-tomcat-6.0.35/webapps/aesconnector/data/log
log_file5=/log/umseval
log_file6=/log/umssmsvalidate
log_file7=/opt/AppServer/apache-tomcat-6.0.35/logs

find $log_file1 -type f -mtime +40 -name 'trace.log.*' -exec rm -rf {} \;
find $log_file2 -type f -mtime +45 -name 'trace.log.*' -exec rm -rf {} \; 
find $log_file3 -type f -mtime +45 -name 'trace.log.*' -exec rm -rf {} \; 
find $log_file4 -type f -mtime +35 -name 'trace.log.*' -exec rm -rf {} \; 
find $log_file5 -type f -mtime +45 -name 'trace.log.*' -exec rm -rf {} \;
find $log_file6 -type f -mtime +45 -name 'trace.log.*' -exec rm -rf {} \;
find $log_file7 -type f -mtime +10 -name 'catalina.out..*' -exec rm -rf {} \;

log_file1日志文件保留40天,log_file2保留45天,即-mtime +xx表示xx天之前。

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!