logrotate does not compress /var/log/messages
Solution 1:
Adding delaycompress
to the configuration section for /var/log/messages
solved the problem.
From man logrotate
:
delaycompress
Postpone compression of the previous log file to the next rota‐
tion cycle. This only has effect when used in combination with
compress. It can be used when some program cannot be told to
close its logfile and thus might continue writing to the previ‐
ous log file for some time.
I guess sysklogd
, my syslog daemon, cannot be told to close its logfile, and thus this is necessary.
Interestingly, the original configuration I had (without the delaycompress
directive), came straight out of man logrotate
(except I changed weekly
to daily
):
# sample logrotate configuration file
compress
/var/log/messages {
rotate 5
weekly
postrotate
/usr/bin/killall -HUP syslogd
endscript
}
Solution 2:
It's hard to say with just this info, but I can tell you what has saved me a few times.
Logrotate has a debug option that will print a play-by-play of each step it takes to stdout. So in this case you could do:
logrotate -d /etc/logrotate.conf
The output will tell you what exactly is going on. Also, if you want to narrow down the debug output you can do
logrotate -d /etc/logrotate.d/messages
Though you may want to temporarily place the main logrotate.conf options in that files block since specifying the file directly means it will have never read the main configs options. Specifying the individual file also means you can use the -f
(force) option in combination with the debug option to get a look at an actual rotation of the messages file taking place.