I have very good experience with logrotate normally, but on a recent installation using "Amazon Linux" (CentOS 6 deployed by Amazon) on EC2, logrotate fails to cause Apache to reopen its logs.
The logrotate configuration for Apache is slightly modified from the default - because of the high traffic on the site, the minimal requirements for keeping old logs and the small amount of space available on the EC2 instance store, we rotate the logs daily and only keep 2 days old files:
# cat /etc/logrotate.d/httpd
/var/log/httpd/*log {
missingok
notifempty
sharedscripts
daily
rotate 2
compress
postrotate
/sbin/service httpd reload > /dev/null 2>/dev/null || true
endscript
}
The rotation itself works fine and the old logs are compressed. But Apache doesn't actually reopen the log files after logrotate deletes the old files, and as a result the old files are not actually removed and Apache keeps piping data into them - eating up the available space and actually losing the log data because its not accessible.
If I run the postrotate script manually from the command line (with sudo or as root) then Apache reopens the log and I get the expected behavior.
There is nothing interesting in the logs (the cron logs says "logrotate started" followed by "logrotate finished") and the system mail has no notifications about problems with the cron job.
This has been going on for a couple of weeks now (since we moved the production server from a Debian based install to an "Amazon Linux" based install) and I'm now quite clueless as to what to do to track down the problem. Any help will be appreciated.