zoukankan      html  css  js  c++  java
  • How to Rotate Tomcat catalina.out

    If catalina.out becomes 2GB in size, tomcat crashes and fails to start without any error message. To avoid this scenario you should rotate catalina.out frequently. This article describes how to setup auto rotation of catalina.out on a linux/unix machine.

    How to automatically rotate catalina.out daily or when it becomes bigger than 5M

    1. Create this file

    /etc/logrotate.d/tomcat

    2. Copy the following contents into the above file

    /var/log/tomcat/catalina.out {   copytruncate   daily   rotate 7   compress   missingok   size 5M  }

    About the above configuration:

    • Make sure that the path /var/log/tomcat/catalina.out above is adjusted to point to your tomcat’s catalina.out
    • daily - rotates the catalina.out daily
    • rotate – keeps at most 7 log files
    • compress – compressesthe rotated files
    • size – rotates if the size of catalina.out is bigger than 5M

    You don’t need to do anything else.

    How it works

    1. Every night the cron daemon runs jobs listed in the /etc/cron.daily/ directory
    2. This triggers the /etc/cron.daily/logrotate file which is generally shipped with linux installations. It runs the command “/usr/sbin/logrotate /etc/logrotate.conf
    3. The /etc/logrotate.confincludes all scripts in the/etc/logrotate.d/ directory.
    4. This triggers the /etc/logrotate.d/tomcat file that you wrote in the previous step.

    Run logrotate manually

    Run the following command to run the cron job manually

    /usr/sbin/logrotate /etc/logrotate.conf

    More logrotate options

    To see all logrotate options on your system, see the manual:

    man logrotat

    https://dzone.com/articles/how-rotate-tomcat-catalinaout
  • 相关阅读:
    OO设计精要:封装,还是封装(有感于“Why getter and setter methods are evil ”by Allen Holub )
    博客园建议:能否记住在博客园的首页上只显示标题
    戴尔国际英语
    C#代码契约(转)
    C#数组传递和返回
    SecureString
    里氏替换原则
    ASP.NET的Cache(转)
    WCF服务
    C#枚举中的位运算权限分配
  • 原文地址:https://www.cnblogs.com/diyunpeng/p/6361757.html
Copyright © 2011-2022 走看看