Logrotate with catalina.out "daily compressed file is overwriting the logs"

Hi Everyone,

We are trying to do a logrotate for "catalina.out" daily, So have used the "copytruncate" option in the logrotate configuration but ended up seeing there was a 0kb file touched with "catalina.out" and the other file with the current date(compressed) file created and seems the log is writing to it as below.

The expected behavior is the log should be written to "catalina.out" and there should not be a today dated compressed file that is getting written. Can someone please suggest..

Config:

/var/log/tomcat/catalina.out {
    copytruncate
    daily
    rotate 7
    compress
    missingok
}
Log file:
-rw-rw-r-- 1 tomcat www 139K Dec 21 03:39 catalina.out-20151220.gz
-rw-rw-r-- 1 tomcat www  20K Jan  5 06:48 catalina.out-20160105.gz
-rw-rw-r-- 1 tomcat www 3.9K Jan  6 03:11 catalina.out-20160106.gz
-rw-rw-r-- 1 tomcat www  11K Jan  7 03:43 catalina.out-20160107.gz
-rw-rw-r-- 1 tomcat www 2.9K Jan  8 03:41 catalina.out-20160108.gz   ----- it's getting updated here & it should have not been compressed today..
-rw-rw-r-- 1 tomcat www    0 Jan  8 03:41 catalina.out  ----- Expecting this file to be updated
 logrotate.d]$ date
Fri Jan  8 06:41:34 CST 2016

-
Thiyags.

I fail to see your logic. It would appear that sometime between 3 and 7 am every morning, the current log file is closed, renamed (adding the current date to the name) and compressed, and a new catalina.out log file is created.

There is no indication that anything has been added to the renamed and compressed log file ( catalina.out-20160108.gz ) after the log was rotated since the renamed compress log file and the new log file both have the same date stamp. Since the daily compressed log files are all under 140Kb, it does not appear that the uncompressed log files are "big". You have given us no indication of when the file listing you showed us was made. But, there is no indication that anything has been written to either of these files since catalina.out was last rotated at 3:41 in the morning on the 8th of January.

1 Like

Hi Don,

Thanks for your valuable response, Am doing a testing with the test boxes so there will no flow in logs here. Also once we succeed with our other testings then we will implement along this into our production servers.

And yes now i have waited to watch the changes, And am pretty ok with this logrotation stuff. Once again thanks for clearing the dark.

Now:

 -rw-rw-r-- 1 tomcat www  12M Dec 22 03:07 catalina.out-20151222
-rw-rw-r-- 1 tomcat www  12K Jan  6 03:09 catalina.out-20160106.gz
-rw-rw-r-- 1 tomcat www 2.1K Jan  7 03:29 catalina.out-20160107.gz
-rw-rw-r-- 1 tomcat www 2.2K Jan  8 03:36 catalina.out-20160108.gz
-rw-rw-r-- 1 tomcat www 1.9K Jan  9 03:29 catalina.out-20160109.gz
-rw-rw-r-- 1 tomcat www  229 Jan 10 03:28 catalina.out-20160110.gz
-rw-rw-r-- 1 tomcat www  86K Jan 11 00:02 catalina.out
[uxadmin@ds6-testa-er-1 datasite]$ date
Mon Jan 11 01:46:16 CST 2016
]$ 

-
Thiyags