centOS6.5 修改catalina.sh使用crontab自动切割日志tomcat8

Posted srain12

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了centOS6.5 修改catalina.sh使用crontab自动切割日志tomcat8相关的知识,希望对你有一定的参考价值。

1、添加LD_LIBRARY_PATH

#!/bin/sh
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/apr/lib
export LD_LIBRARY_PATH

 

2、修改jvm参数

# OS specific support. $var _must_ be set to either true or false.
#export JAVA_OPTS="-server -Dfile.encoding=UTF-8 -Duser.language=zh_CN -Xms1196M -Xmx1196M -Xmn548M -Xss512K -XX:+AggressiveOpts -XX:+UseBiasedLocking -XX:PermSize=88M -XX:MaxPermSize=106M -XX:SurvivorRatio=2 -XX:MaxTenuringThreshold=30 -XX:LargePageSizeInBytes=64m -XX:+UseParallelOldGC -XX:GCTimeRatio=9 -Djava.awt.headless=true -Duser.timezone=GMT+08"
export JAVA_OPTS="-server -Dfile.encoding=UTF-8 -Duser.language=zh_CN -Xms3048M -Xmx3048M -Xmn1452M -XX:+AggressiveOpts -XX:+UseBiasedLocking -XX:PermSize=70M -XX:MaxPermSize=90M -XX:+DisableExplicitGC -XX:MaxTenuringThreshold=31 -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+CMSParallelRemarkEnabled -XX:+UseCMSCompactAtFullCollection -XX:LargePageSizeInBytes=64m -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly -Djava.awt.headless=true -Duser.timezone=GMT+08"

 

3、引入crontab日志切割

touch "$CATALINA_OUT"
if [ "$1" = "-security" ] ; then
if [ $have_tty -eq 1 ]; then
echo "Using Security Manager"
fi
shift
eval $_NOHUP "\"$_RUNJAVA\"" "\"$LOGGING_CONFIG\"" $LOGGING_MANAGER $JAVA_OPTS $CATALINA_OPTS \
-classpath "\"$CLASSPATH\"" \
-Djava.security.manager \
-Djava.security.policy=="\"$CATALINA_BASE/conf/catalina.policy\"" \
-Dcatalina.base="\"$CATALINA_BASE\"" \
-Dcatalina.home="\"$CATALINA_HOME\"" \
-Djava.io.tmpdir="\"$CATALINA_TMPDIR\"" \
org.apache.catalina.startup.Bootstrap "[email protected]" start \
>> "$CATALINA_OUT" 2>&1 "&"

else
eval $_NOHUP "\"$_RUNJAVA\"" "\"$LOGGING_CONFIG\"" $LOGGING_MANAGER $JAVA_OPTS $CATALINA_OPTS \
-classpath "\"$CLASSPATH\"" \
-Dcatalina.base="\"$CATALINA_BASE\"" \
-Dcatalina.home="\"$CATALINA_HOME\"" \
-Djava.io.tmpdir="\"$CATALINA_TMPDIR\"" \
org.apache.catalina.startup.Bootstrap "[email protected]" start \

>> "$CATALINA_OUT" 2>&1 "&"


修改为:

# touch "$CATALINA_OUT"
if [ "$1" = "-security" ] ; then
if [ $have_tty -eq 1 ]; then
echo "Using Security Manager"
fi
shift
eval $_NOHUP "\"$_RUNJAVA\"" "\"$LOGGING_CONFIG\"" $LOGGING_MANAGER $JAVA_OPTS $CATALINA_OPTS \
-classpath "\"$CLASSPATH\"" \
-Djava.security.manager \
-Djava.security.policy=="\"$CATALINA_BASE/conf/catalina.policy\"" \
-Dcatalina.base="\"$CATALINA_BASE\"" \
-Dcatalina.home="\"$CATALINA_HOME\"" \
-Djava.io.tmpdir="\"$CATALINA_TMPDIR\"" \
org.apache.catalina.startup.Bootstrap "[email protected]" start \

2>&1 |/usr/local/sbin/cronolog "$CATALINA_BASE/logs/catalina-%Y-%m-%d.out" &

else
eval $_NOHUP "\"$_RUNJAVA\"" "\"$LOGGING_CONFIG\"" $LOGGING_MANAGER $JAVA_OPTS $CATALINA_OPTS \
-classpath "\"$CLASSPATH\"" \
-Dcatalina.base="\"$CATALINA_BASE\"" \
-Dcatalina.home="\"$CATALINA_HOME\"" \
-Djava.io.tmpdir="\"$CATALINA_TMPDIR\"" \
org.apache.catalina.startup.Bootstrap "[email protected]" start \

2>&1 |/usr/local/sbin/cronolog "$CATALINA_BASE/logs/catalina-%Y-%m-%d.out" &













































以上是关于centOS6.5 修改catalina.sh使用crontab自动切割日志tomcat8的主要内容,如果未能解决你的问题,请参考以下文章

centos tomcat6找不到catalina.sh文件

linux使用shutdown.sh命令关闭不完tomcat进程的处理方法

catalina.out日志切割

tomcat 日志禁用

Tomcat关闭日志输出

tomcat 日志禁用