-   Linux - Server (
-   -   Strange logrotate issue. (

dxangel 08-23-2010 06:07 AM

Strange logrotate issue.
Strange problem that i cant seem to figure out.

Centos5.3, Apache2
logrotate as standard.

Logrotate will not correctly roll the logs, despite many httpd restarts ( new pids checked and correspond ) and forced manual logrotates.

August 18 and 23 show my forced logrotates.
-rw-r--r-- 1 root root 0 Aug 19 04:02 access_log
-rw-r--r-- 1 root root 660003669 Aug 23 11:51 access_log.1
-rw-r--r-- 1 root root 0 Aug 12 04:03 access_log.2
-rw-r--r-- 1 root root 0 Aug 11 04:03 access_log.3
-rw-r--r-- 1 root root 0 Aug 10 04:03 access_log.4
-rw-r--r-- 1 root root 1573047575 Aug 18 10:40 access_log.5

After a forced logrotate, httpd will start to log to access.log and the problem appears solved. However when the logs rotate out of cron.daily as speficied, apache keeps writing to the old log.

/etc/logrotate.d/httpd contents:

/var/log/httpd/access_log /var/log/httpd/error_log {
rotate 5
mail ****@***
/bin/kill -HUP `cat /var/log/httpd/ 2>/dev/null` 2> /de
v/null || true

This exact configuration is working on another machine, which did show similar symptoms but resolved itself after a force and restart. So this is a known working configuration.

Contents of /var/lib/logrotate.status


"/var/log/httpd/access_log" 2010-8-19
"/var/log/httpd/error_log" 2010-8-19

As shown, the logs havent rotated since i last forced it on the cmd line.

Other logs such as messages, secure, maillog, spooler, boot have all rotated correctly and the timestamps are correct.

this machine uses NTP. $date is correct.

/etc/logrotate.conf shows included path /etc/logrotate.d . All other configuration looks correct.

httpd config is identical to known working server. However, for completeness:

# Logging:
ErrorLog "logs/error_log"
LogLevel warn
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" co
LogFormat "%h %l %u %t \"%r\" %>s %b" common
<IfModule logio_module>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %
I %O" combinedio
CustomLog "logs/access_log" combined

All permissions on all files are correct and comparable to known working.

I do not want to use piped logs or cronolog.

Looking forward to any thoughts anyone might have.

AlucardZero 08-23-2010 07:19 AM

I've run into this; I think I "solved" it by restarting apache instead of just HUPing it. You might also try logrotate's "copytruncate" option. Now, subscribing to this topic because I want to know a better way..

dxangel 08-23-2010 08:12 AM

thanks AlucardZero, ive restarted httpd, not just HUP'd it manually and it did seem to work, until next time it ran and HUP'd from cron.

What bothers me is that these machines are identical, suffered from the same issue, but one is fixed and one isnt. Im starting to think theres a bug somewhere. The 'easy way' would be to rewrite the logrotate conf to restart httpd but its a bodge, not a solution.

Im also aware of 'copytruncate' but using this method means loging some logs. Im not sure i want to do that.

All times are GMT -5. The time now is 07:05 AM.