Reuben D. Budiardja wrote:
Hello,
I have Apache installed/compiled from source in my server (*not* from RPM). In its httpd.conf, I specify so that it writes its log in /var/log/apache/logs/. The log files are access_log and error_log.


So I read the man page for logrotate, and thought to play around with it. I want the apache logs to be rotated, and I add these to my /etc/logrotate.conf:

# rotate apache logs (added by reubendb)
/var/log/apache/logs/access_log {
  rotate 5
  weekly
}

/var/log/apache/logs/error_log {
  rotate 5
  weekly
}

It seems that logrotate works fine. In my /var/log/apache/logs directory now I can see access_log, access_log.1, error_log, error_log.1, etc.

But apparently when the log files are rotated, apache keep writing to the old one. So right now my Apache still writes to access_log.2 and error_log.2. Both access_log and error_log are empty, and so are access_log.1 and error_log.1

This, I think, kinda make sense if Apache already opened the file and keep it open. logrotate changes the logname, but apache keep "refers" to the file itself. If I restart Apache, then it will write to access_log and error_log.

So my question is, how do I solve this problem?

Thanks a lot for any help.
RDB

I do it this way:


/var/log/apache/logs/access_log /var/log/apache/logs/error_log {
   rotate 5
   weekly
   sharedscripts
   postrotate
      /usr/bin/killall -HUP httpd
}

The sharedscripts line tell logrotate to do wait to do the following script until after all files listed are rotated. The postrotate lines stop and restart the server.

HTH,

Bill


-- redhat-list mailing list unsubscribe mailto:[EMAIL PROTECTED] https://www.redhat.com/mailman/listinfo/redhat-list

Reply via email to