В файл /etc/logrotate.d/tomcat
заносим:
/var/log/tomcat/catalina.out { copytruncate daily rotate 60 dateext compress missingok }
Советы найдены по адресу How to Rotate Tomcat catalina.out (http://java.dzone.com/articles/how-rotate-tomcat-catalinaout) и How to compress and clean logs with logrotate but not rotate them (http://serverfault.com/questions/247563/how-to-compress-and-clean-logs-with-logrotate-but-not-rotate-them).
Ключевой момент — использование опции copytruncate
copytruncate Truncate the original log file to zero size in place after creating a copy, instead of moving the old log file and optionally creating a new one. It can be used when some program cannot be told to close its logfile and thus might continue writing (appending) to the previous log file forever. Note that there is a very small time slice between copying the file and truncating it, so some logging data might be lost. When this option is used, the create option will have no effect, as the old log file stays in place.
Leave a Reply
You must be logged in to post a comment.