标签:download backup 根目录 home span out base security back
Linux 日志切割工具cronolog详解:https://blog.csdn.net/chenkeqin_2012/article/details/52670887
wget http://cronolog.org/download/cronolog-1.6.2.tar.gz tar zxvf cronolog-1.6.2.tar.gz cd cronolog-1.6.2 ./configure make && make install
which cronolog 一般情况下显示为:/usr/local/sbin/cronolog
找到下面这行,类似这样的行有2处:
org.apache.catalina.startup.Bootstrap "$@" start >> "$CATALINA_OUT" 2>&1 &
# touch "$CATALINA_OUT"
if [ "$1" = "-security" ] ; then if [ $have_tty -eq 1 ]; then echo "Using Security Manager" fi shift "$_RUNJAVA" "$LOGGING_CONFIG" $LOGGING_MANAGER $JAVA_OPTS $CATALINA_OPTS -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" -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 "$@" start >> "$CATALINA_OUT" 2>&1 & else "$_RUNJAVA" "$LOGGING_CONFIG" $LOGGING_MANAGER $JAVA_OPTS $CATALINA_OPTS -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" -classpath "$CLASSPATH" -Dcatalina.base="$CATALINA_BASE" -Dcatalina.home="$CATALINA_HOME" -Djava.io.tmpdir="$CATALINA_TMPDIR" org.apache.catalina.startup.Bootstrap "$@" start 2>&1 | /usr/local/sbin/cronolog /usr/local/tomcat/logs/catalina.%Y%m%d.out >> /dev/null & # >> "$CATALINA_OUT" 2>&1 & fi
查看日志目录是否生成catalina.yymmdd.out的日志文件
-rw-r--r-- 1 root root 10537 Jul 30 10:50 catalina.20140730.out
配置cronolog完成了,观察每天是否有一个新的catalina.yymmdd.out的日志文件生成,定期删除日期较旧的日志文件。
log4j.rootLogger=INFO, R log4j.appender.R=org.apache.log4j.RollingFileAppender log4j.appender.R.File=${catalina.home}/logs/tomcat.newlog #设定日志文件名 log4j.appender.R.MaxFileSize=100KB #设定文件到100kb即分割 log4j.appender.R.MaxBackupIndex=10 #设定日志文件保留的序号数 log4j.appender.R.layout=org.apache.log4j.PatternLayout log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n
#!/bin/bash cd `dirname $0` d=`date +%Y%m%d` d7=`date -d‘7 day ago‘ +%Y%m%d` cd ../logs/ cp catalina.out catalina.out.${d} echo "" > catalina.out rm -rf catalina.out.${d7}
标签:download backup 根目录 home span out base security back
原文地址:https://www.cnblogs.com/happy-king/p/9193401.html