#!/bin/bash#logs_paths#logs_paths[0]= "/usr/local/webserver/tomcat/logs"#logs_paths[1]= "/usr/local/webserver/task_tomcat_8102/logs"#logs_paths[2]= "/usr/local/webserver/console_tomcat_8101/logs"#For Logs_path in ${logs_paths[@]}# Do#echo ' 123131312 '#Find $logs _path-mtime +7-name "Localhost_access_log.*.txt"-exec rm-rf {} \;#Find $logs _path-mtime +7-name "Catalina.*.log"-exec rm-rf {} \;#Find $logs _path-mtime +7-name "Manager.*.log"-exec rm-rf {} \;#Find $logs _path-mtime +7-name "Host-manager.*.log"-exec rm-rf {} \;#Find $logs _path-mtime +7-name "fileservice.log.*"-exec rm-rf {} \;# Done#logs_paths#logs_paths[0]= "/usr/local/webserver/tomcat/logs"logs_paths[0]="/usr/local/webserver/task_tomcat_8102/logs"#logs_paths[1]= "/usr/local/webserver/console_tomcat_8101/logs" forLogs_pathinch${logs_paths[@]}; DoFind$logs _path-mtime +7-name"Localhost_access_log.*.txt"-exec RM-RF {} \; Find$logs _path-mtime +7-name"Catalina.*.log"-exec RM-RF {} \; Find$logs _path-mtime +7-name"Manager.*.log"-exec RM-RF {} \; Find$logs _path-mtime +7-name"Host-manager.*.log"-exec RM-RF {} \; Find$logs _path-mtime +7-name"fileservice.log.*"-exec RM-RF {} \; Find$logs _path-mtime +7-name"Localhost.*.log"-exec RM-RF {} \; CP$logs _path/catalina.out$logs _path/catalina. ' Date +%y-%m-%d '. Log Cat/dev/null >$logs _path/Catalina.out Echo$logs _path Done
Ubuntu scheduled backup cleans up the Tomcat logs and deletes logs up to seven days ago