#!/bin/bashwhile truedo cd /usr/local/tomcat/logs d=`date +%Y%m%d` d15=`date -d'15 day ago' +%Y%m%d` cp catalina.out /opt/logs/catalina.out.${d} echo " " > catalina.out rm -rf catalina.out.${d15} sleep 86400done
每天切割一次,并删除15天之前的日志:
放到后台执行:
yum -y install screenscreen
./tomcatlog.sh &
ctrl + a + d退出即可