Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Server
User Name
Linux - Server This forum is for the discussion of Linux Software used in a server related context.


  Search this Thread
Old 08-23-2010, 06:07 AM   #1
Registered: Nov 2008
Location: London, UK
Distribution: CentOS, RedHat, Ubuntu
Posts: 79

Rep: Reputation: 18
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.
Old 08-23-2010, 07:19 AM   #2
Senior Member
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,824

Rep: Reputation: 613Reputation: 613Reputation: 613Reputation: 613Reputation: 613Reputation: 613
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..
Old 08-23-2010, 08:12 AM   #3
Registered: Nov 2008
Location: London, UK
Distribution: CentOS, RedHat, Ubuntu
Posts: 79

Original Poster
Rep: Reputation: 18
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.

Last edited by dxangel; 08-23-2010 at 08:13 AM.


apache2, logrotate

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Strange DNS issue! Atif_Khan Linux - General 2 01-27-2007 07:49 AM
Logrotate issue stefaandk Fedora 1 01-09-2007 03:17 AM
Logrotate strange problem FragInHell Linux - Software 3 05-07-2006 06:12 PM
strange c issue exvor Programming 8 01-29-2005 02:23 PM
help me on a strange issue. newpenguin Linux - General 11 10-06-2002 03:42 PM > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 06:30 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration