tomcat切割日志的shell脚本

#!/bin/bash
cd /usr/tomcats/
d=`date +%F`
m1=`date -d'1 month ago' +%F`

for i in `seq 8`
do
    cd tomcat808"$i"/logs
    cp catalina.out catalina.out.$d
    echo " " > catalina.out
    rm -rf catalina.out.$m1
    cd ../..
done

将脚本添加到任务计划中:05 02 * * * /bin/bash /usr/tomcats/tomcatlog.sh

posted @ 2016-08-18 15:57  fansik  阅读(175)  评论(0编辑  收藏  举报