shell方式切割tomcat日志

#!/bin/bash
while true
do
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
done

每天切割一次,并删除15天之前的日志:

放到后台执行:
yum -y install screen

screen

./tomcatlog.sh &

ctrl + a + d退出即可

上一篇:study notes for python


下一篇:Objective-C( 语法一)