Discuz! Board

标题: tomcat日志切割 [打印本页]

作者: admin    时间: 2017-4-27 17:59
标题: tomcat日志切割
安装cronolog包
yum -y install cronolog.x86_64

sed脚本
#!/bin/bash
#
cp  ./catalina.sh ./catalina.sh.bak
sed -i s#'CATALINA_OUT="$CATALINA_BASE"/logs/catalina.out'#'CATALINA_OUT="$CATALINA_BASE"/logs/catalina.%Y-%m-%d.out'#g $1
sed -i s/'touch "$CATALINA_OUT"'/'#touch "$CATALINA_OUT"'/g $1
sed -i 's@>> "$CATALINA_OUT" 2>&1 "&"@\| \/usr\/sbin\/cronolog \"$CATALINA_OUT\" \>> \/dev\/null \&@g' $1
sed -i 's@start \\@start 2\>\&1 \\@g' $1


重启Tomcat






欢迎光临 Discuz! Board (http://123.59.83.120:8080/) Powered by Discuz! X3.2