0

This is related to logrotate not able to truncate catalina.out which is incorrectly closed as a duplicate, even though the duplicate question describes a subtly different issue with a very different solution.

Question (abbreviated to the relevant parts for brevity):

With the following logrotate configuration, why does the log rotate, but catalina.out does not get truncated? (This is different from the behavior in the question linked as a duplicate, where rotating did not happen at all).

/log/apache-tomcat/catalina.out{
 copytruncate
 daily
 size 256M
 rotate 8
 missingok
 maxage 7
}

logrotate -v verifies that copying the log file, compressing and truncating all are happening.

1 Answer 1

0

This happens because the catalina.out file is usually not owned by root, but by a user such as tomcat:tomcat.

> ls -lah /log/apache-tomcat/catalina.out
-rw-r--r-- 1 tomcat tomcat 105K Nov  4 13:48 catalina.out

To solve this issue, you have to add the line "su tomcat tomcat" to the logrotate configuration.

/log/apache-tomcat/catalina.out{
 su tomcat tomcat
 copytruncate
 daily
 size 256M
 rotate 8
 missingok
 maxage 7
}

As an aside, having both entries daily and size 256M is contradictory. Either rotate every day, or rotate when the log file reaches the specified size, but not both.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .