log_path=/usr/local/tomcat/logs d=`date +%Y-%m-%d` d30=`date -d'30 day ago' +%Y-%m-%d` cd ${log_path} && cp catalina.out $log_path/catalina.out/catalina.out.$d.log echo > catalina.out rm -rf $log_path/catalina.out/catalina.out.${d30}.log
添加权限
chmod 777 /usr/local/tomcat/log_cron.sh
编辑crontab
crontab -e
50 23 * * * sh /usr/local/tomcat/log_cron.sh