用cronolog-1.6.2 将Tomcat catalina.out日志按日分割

1、下载cronolog-1.6.2,http://pan.baidu.com/s/1eRPtp2y

2、将cronolog-1.6.2上传至linux服务器的/opt文件夹下

3、安装时依次执行的命令:

(1)cd /opt/apache-tomcat-8.0.30/bin/
(2)sh shutdown.sh
(3)ps -ef|grep tomcat
(4)kill -9 6968
(5)cd /opt/     
(6)ls
(7)tar zxvf cronolog-1.6.2.tar.gz
(8)ls
(9)cd cronolog-1.6.2
(10)./configure 
(11)make
(12)make install
(13)which cronolog     会显示默认安装路径 /usr/local/sbin/cronolog
(14)cd /opt/
(15)cd /opt/apache-tomcat-8.0.30/bin/
(16)ls
(17)vim catalina.sh

①找到下面的字符串,按i进行修改,共2处:
org.apache.catalina.startup.Bootstrap “$@” start  \   
>> “$CATALINA_BASE”/logs/catalina.out 2>&1 &  
修改为 
org.apache.catalina.startup.Bootstrap "$@" start  2>&1 \   
    | /usr/local/sbin/cronolog "$CATALINA_BASE"/logs/catalina.%Y-%m-%d.out >> /dev/null &  
②同时注释掉上面的touch “$CATALINA_BASE”/logs/catalina.out

③按esc后输入wq回车保存退出
(18)sh startup.sh
(19)tail -f /opt/apache-tomcat-8.0.30/logs/catalina.2017-07-20.out 

你可能感兴趣的:(tomcat)