• Cronolog切割tomcat日志


    Cronolog切割tomcat

    安装cronolog

    1、 cronolog-1.6.2.tar.gz 上传至/opt 目录

    2、 解压缩

    #解压缩

    tar -zxvf cronolog-1.6.2.tar.gz

    #修改文件夹

    mv cronolog-1.6.2/ cronolog

    3、 安装

    #进入cronolog目录

        cd cronolog/

    ./configure

    make

    make install

    4、 检验是否安装完成

    which cronolog

    #一般情况下显示为:/usr/local/sbin/cronolog 

    修改配置文件(或者直接替换)

    1、 停止tomcat

    2、 进入tomcat/bin 目录

    cd /usr/local/tomcat6/bin/

    3、 修改配置文件

    vi catalina.sh

    # 注释掉355

    touch "$CATALINA_OUT"  修改为  #touch "$CATALINA_OUT"

    #修改 368369

    org.apache.catalina.startup.Bootstrap "$@" start

    >> "$CATALINA_OUT" 2>&1 &

    修改为

    org.apache.catalina.startup.Bootstrap "$@" start  2>&1

    | /usr/local/sbin/cronolog "$CATALINA_BASE"/logs/catalina.%Y-%m-%d_%H.out >> /dev/null &

    #修改 377378

    org.apache.catalina.startup.Bootstrap "$@" start

    >> "$CATALINA_OUT" 2>&1 &

    修改为

    org.apache.catalina.startup.Bootstrap "$@" start  2>&1

    | /usr/local/sbin/cronolog "$CATALINA_BASE"/logs/catalina.%Y-%m-%d_%H.out >> /dev/null &

    4、 重启tomcat

    ###############################################################################

    替换文件:

    附件中的catalina.sh 为已修改过的。将改文件直接替换即可。(需要比较该文件替换前后的执行权限。)

    tomcat8.5可能显示不太一样:

    建议将第453-491的代码shift
      if [ -z "$CATALINA_OUT_CMD" ] ; then
        touch "$CATALINA_OUT"
        catalina_out_command=">> "$CATALINA_OUT" 2>&1"
      else
        catalina_out_command="| $CATALINA_OUT_CMD"
      fi
      if [ ! -z "$CATALINA_PID" ]; then
        catalina_pid_file="$CATALINA_PID"
      else
        catalina_pid_file=/dev/null
      fi
      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
          -D$ENDORSED_PROP=""$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
          2>&1 && echo $! >"$catalina_pid_file" ; } $catalina_out_command "&"

      else
        eval { $_NOHUP ""$_RUNJAVA"" ""$LOGGING_CONFIG"" $LOGGING_MANAGER $JAVA_OPTS $CATALINA_OPTS
          -D$ENDORSED_PROP=""$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 && echo $! >"$catalina_pid_file" ; } $catalina_out_command "&"

      fi

    直接替换为

    shift
      #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  2>&1
            | /usr/local/sbin/cronolog "$CATALINA_BASE"/logs/catalina.%Y-%m-%d_%H.out >> /dev/null &

      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 "$CATALINA_BASE"/logs/catalina.%Y-%m-%d_%H.out >> /dev/null &

      fi

  • 相关阅读:
    LeetCode 965. Univalued Binary Tree
    LeetCode 961. N-Repeated Element in Size 2N Array
    LeetCode 832. Flipping an Image
    语法设计——基于LL(1)文法的预测分析表法
    简单的词法设计——DFA模拟程序
    LeetCode 905. Sort Array By Parity
    LeetCode 804. Unique Morse Code Words
    【原创】用事实说话,Firefox 的性能是 Chrome 的 2 倍,Edge 的 4 倍,IE11 的 6 倍!
    【新特性速递】新增单标签页模式,界面更加清爽!
    【新特性速递】重构表格列锁定代码,只有一个横向滚动条,更加现代化!
  • 原文地址:https://www.cnblogs.com/baobeiqi-e/p/10521522.html
Copyright © 2020-2023  润新知