首页 > 代码库 > ubuntu 定时备份清理tomcat日志,并且删除七天之前的日志
ubuntu 定时备份清理tomcat日志,并且删除七天之前的日志
#!/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" for logs_path in ${logs_paths[@]}; do 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 {} \; 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 定时备份清理tomcat日志,并且删除七天之前的日志
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。