Logrotate httpd (apache) logs – Possible without reloading httpd after log purge

apache-2.2logrotate

Lets start with a small dump:

/var/log/httpd/*log {
    compress
    missingok
    notifempty
    sharedscripts
    delaycompress
    postrotate
        /sbin/service httpd reload > /dev/null 2>/dev/null || true
    endscript
}

This is a dump of of our httpd logrotate.d file.

As you can see, after the files are rotated, apache is "reloaded".

Is it ok to disable this?

We reverse proxy (via nginx) to our apache boxes and have noticed when this is executed (httpd reload) there is 2-5 seconds of downtime (noticed as in, via our nginx reverse proxy logs).

We would like to disable this.

Any ideas how to rotate apache logs without sending a reload once they have been rotated?

Thanks!

Best Answer

You can use Apache's piped logs. You can write the piped stream to file yourself and handle the rotation inside the script. Apache does not need to be reloaded then.