Tomcat 的 catalina.out 日誌量不斷增長,佔用空間較大,且默認是不滾動的。所以,須要對其進行日誌分割,並進行清理。apache
本文選用 Cronolog 對其進行分割。vim
地址:http://cronolog.org/download/cronolog-1.6.2.tar.gzide
# tar zxvf cronolog-1.6.2.tar.gz測試
# cd cronolog-1.6.2spa
# ./configure日誌
# makeip
# make installget
查看 cronolog 安裝後所在目錄,驗證安裝是否成功:it
# which cronologio
通常狀況下顯示爲:/usr/local/sbin/cronolog
vim /data/Application/oa-mis-hrbp/bin/catalina
1)第一步
if [ -z "$CATALINA_OUT" ] ; then
CATALINA_OUT="$CATALINA_BASE"/logs/catalina.out
改成
if [ -z "$CATALINA_OUT" ] ; then
CATALINA_OUT="$CATALINA_BASE"/logs/catalina.%Y-%m-%d.log
2)第二步
touch "$CATALINA_OUT"
改成
#touch "$CATALINA_OUT"
3)第三步
org.apache.catalina.startup.Bootstrap "$@" start \
>> "$CATALINA_OUT" 2>&1 "&"
改成
org.apache.catalina.startup.Bootstrap "$@" start 2>&1 \
|/usr/local/sbin/cronolog "$CATALINA_OUT" >> /dev/null &
3)第四步
org.apache.catalina.startup.Bootstrap "$@" start \
>> "$CATALINA_OUT" 2>&1 "&"
改成
org.apache.catalina.startup.Bootstrap "$@" start 2>&1 \
|/usr/local/sbin/cronolog "$CATALINA_OUT" >> /dev/null &
重啓後,查看日誌是否分割成功。