crontab定时清除tomcat30天前的日志
建立 clean.sh,内容如下:
#!/bin/bash
#0 2 1 * * sh /mnt/tomcat/apache-tomcat-8.5.23/logs/clean.sh
logs_path="/mnt/tomcat/apache-tomcat-8.5.23/logs"
find $logs_path -mtime +30 -name "localhost.*.log" -exec rm -rf {} \;
find $logs_path -mtime +30 -name "localhost_access_log.*.txt" -exec rm -rf {} \;
find $logs_path -mtime +30 -name "catalina.*.log" -exec rm -rf {} \;
find $logs_path -mtime +30 -name "manager.*.log" -exec rm -rf {} \;
find $logs_path -mtime +30 -name "host-manager.*.log" -exec rm -rf {} \;
find $logs_path -mtime +30 -name "fileservice.log.*" -exec rm -rf {} \;
>$logs_path/catalina.out;
网友评论