Tomcat在Linux下catalina.out文件不断膨胀的解决方法
以下在Linux RedHat Enterprise5.0和Tomcat5.5环境下测试通过。
- 通过http://cronolog.org/download/index.html下载cronolog-1.6.2.tar.gz
- 使用root用户上传cronolog-1.6.2.tar.gz
- 使用tar -zxvf cronolog-1.6.2.tar.gz解压cronolog-1.6.2.tar.gz
- 进入解压目录,执行命令
./configure
make
make install - 然后修改tomcat的catalian.sh文件(做好备份)
修改:
org.apache.catalina.startup.Bootstrap "$@" start \
>> "$CATALINA_BASE"/logs/catalina.out 2&1 &
为:
org.apache.catalina.startup.Bootstrap "$@" start \
|/usr/local/sbin/cronolog "$CATALINA_BASE"/logs/catalina.%Y-%m-%d.out >> /dev/null 2>&1 & - 重新启动Tomcat
上述修改同样适用于Tomcat6
Tomcat7修改如下(在CentOS6.5和Tomcat7.0.53测试通过)
- 安装cronolog方法相同
- 修改tomcat的catalian.sh文件(2处)
第一处:
CATALINA_OUT="$CATALINA_BASE"/logs/catalina.out
改为:
CATALINA_OUT="$CATALINA_BASE"/logs/catalina.%Y-%m-%d.out
第二处:
touch "$CATALINA_OUT"
if [ "$1" = "-security" ] ; then
......
org.apache.catalina.startup.Bootstrap "$@" start \
>> "$CATALINA_OUT" 2>&1 "&"
else
......
org.apache.catalina.startup.Bootstrap "$@" start \
>> "$CATALINA_OUT" 2>&1 "&"
fi
改为:
#touch "$CATALINA_OUT"
if [ "$1" = "-security" ] ; then
......
org.apache.catalina.startup.Bootstrap "$@" start 2>&1 \
| /usr/local/sbin/cronolog "$CATALINA_OUT" >> /dev/null &
else
......
org.apache.catalina.startup.Bootstrap "$@" start 2>&1 \
| /usr/local/sbin/cronolog "$CATALINA_OUT" >> /dev/null &
fi
说明:如果使用yum安装cronolog(EPEL源),则cronolog在/usr/sbin目录下。
相关推荐
Kafka 2020-09-18
Wepe0 2020-10-30
杜倩 2020-10-29
windle 2020-10-29
minerd 2020-10-28
mengzuchao 2020-10-22
Junzizhiai 2020-10-10
bxqybxqy 2020-09-30
风之沙城 2020-09-24
kingszelda 2020-09-22
大唐帝国前营 2020-08-18
yixu0 2020-08-17
TangCuYu 2020-08-15
xiaoboliu00 2020-08-15
songshijiazuaa 2020-08-15
xclxcl 2020-08-03
zmzmmf 2020-08-03
newfarhui 2020-08-03
likesyour 2020-08-01