Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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!

share|improve this question

2 Answers 2

up vote 4 down vote accepted

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.

share|improve this answer

The reason for the reload is that Apache opens the log file and gets a handle to it when started or reloaded. It will then continue writing to that file handle even if the file is moved, so if you are rotating the files by moving them, you will need to do a reload so it will realise the file is missing and create a new one with a new file handle.

Like Christopher Perrin said, using piped logs is one solution. Another is to use the option

copytruncate

in your logrotate config file. Instead of the log file being moved, it will be copied to its new place and the old file will be truncated. That means that Apache can keep the same filehandle, and doesn't need to be restarted.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.