Background information:
The project has two log folders, one for Tomcat itself, and two for the project.
This script is used in conjunction with Crontab once a week and can be done without restarting the Tomcat catalina.out normal situation to achieve the function of log backup.
#!/bin/sh
#
#2016 -3-25
#andre. Yang
log_path=/home/app/logs
#tomcat_dir = ' dirname $ '
catalina_path=/home/app/apache-tomcat-7.0.57
Back_path=/home/app/portal_bak Find
${catalina_path}/logs- Mtime +6-name "*.log"-exec rm-rf {} \;
Find ${log_path}/portal-mtime +6-name "*.log"-exec rm-rf {} \;
d= ' Date +%y-%m-%d '
cd ${catalina_path} && tar-czvf $d. tomcatlog.tar.gz logs
mv $d. tomcatlog.tar.gz $ {Back_path}
For I in ' find. -name "*.out"; Do cat/dev/null > $i; Done to
I in ' Find.-name ' *.log ', do cat/dev/null > $i, done
cd ${log_path} && tar-czvf $d. log.t ar.gz Portal
mv $d. Log.tar.gz ${back_path} for
i-' Find-name ' *.log ', do cat/dev/null > $i;