cronolog分割tomcat日志文件
tomcat日志备份磁盘压力解决方案,使用cronolog每日生成文件
uat部署操作如下,,观察两天,下周一部署生产message系统,后续根据需求部署到其它业务线
示例方案:uat—message01-202,uat-assets01-124
一、安装 软件
cronolog-1.6.2.tar.gz
tar zxvf cronolog-1.6.2.tar.gz
cd cronolog-1.6.2
./configure && make && make install
或者yum install cronolog -y
[root@lcb-u-message01 logs]# which cronolog
/usr/sbin/cronolog
二、配置 tomcat
找到 tomcat 中 bin 目录下的 catalina.sh 文件
1. 查找
if [ -z "$CATALINA_OUT" ] ; then
CATALINA_OUT=/opt/htdocs/logs/catalina.out
fi
修改为:
if [ -z "$CATALINA_OUT" ] ; then
CATALINA_OUT=/opt/htdocs/logs/catalina.%Y-%m-%d.out
fi
2. 查找 touch "$CATALINA_OUT"
注释掉
#touch "$CATALINA_OUT"
3. 查找 "$CATALINA_OUT" 2>&1 "&"
有两处..
org.apache.catalina.startup.Bootstrap "$@" start \
>> "$CATALINA_OUT" 2>&1 "&"
都修改为 :
org.apache.catalina.startup.Bootstrap "$@" start \
| /usr/sbin/cronolog "$CATALINA_OUT" >> /dev/null &
3. 重启 tomcat 服务,查看日志文件如下
[root@lcb-u-message01 logs]# ll
total 208
-rw-rw-r-- 1 deployer deployer 1647 Aug 11 14:20 catalina.2017-08-11.log
-rw-rw-r-- 1 deployer deployer 196827 Aug 11 14:20 catalina.out20170811