How to Rotate Tomcat catalina.out
Tomcat to How out catalina rotate
2023-09-11 14:16:20 时间
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
- Every night the cron daemon runs jobs listed in the /etc/cron.daily/ directory
- 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“
- The /etc/logrotate.confincludes all scripts in the/etc/logrotate.d/ directory.
- 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
相关文章
- eclipse项目配置tomcat后浏览器访问不到项目解决方案
- 服务管理-tomcat
- TOMCAT源码分析——启动服务
- 从连接器组件看Tomcat的线程模型——BIO模式
- Tomcat启动报Error listenerStart错误 Context [] startup failed due to previous errors
- Java连接Oracle11G,mysql和Tomcat等配置(来自我的ITeye)
- 连接池c3p0 ,Proxool ,Druid ,Tomcat Jdbc Pool对比测试
- Tomcat远程debug
- Tomcat详解(一)——tomcat基础知识
- Atitit webserver tomcat 7 8.0 8.5 9.0新特性 Tomcat 7 的七大新特性 - 编程语言 - ITeye资讯.html tomcat 8.0特性 - CSD
- 【Codeforces 231C】To Add or Not to Add
- 成功解决To fix this you could try to: 1. loosen the range of package versions you‘ve specified
- idea配置tomcat必坑指南
- tomcat链接mysql时超时报错java.io.EOFException: Can not read response from server. Expected to read 4 bytes,
- HTTP转HTTPS—使用OpenSSL创建自签名SSL证书以及Tomcat配置SSL证书实战
- Tomcat无法启动:Server Tomcat v8.5 Server at localhost failed to start
- 在Linux安装配置Tomcat 并部署web应用 ( 三种方式 )
- 【异常】为什么Tomcat不会自动解压?
- 解决idea中的tomcat的输出控制台乱码