Posts

Showing posts with the label Logrotate

Apache2 And Logrotate: Delaycompress Needed?

Answer : If you're doing an Apache restart (or even 'graceful') it will close open file handles and open them again. You shouldn't need delaycompress because the file will have been closed and re-opened as part of your postrotate restart. rotate access_log -> access_log.1 (rename action, no INODE change) apache still writing to access_log.1 (same open FD on same INODE) apache restart (close FD, release INODE writing) apache writing to access_log (new FD to a new INODE) A restart is kind of a bad idea - what if the config file accidentally changed and is no longer valid? Your apache won't start back up. Instead send a HUP to the parent process which tells it to close/re-open file handles. postrotate /bin/kill -HUP `cat /var/run/apache2.pid 2>/dev/null` 2>/dev/null || true endscript cat will fail if the PID is missing (or empty, or invalid) causing kill to also fail so you don't need the if..then block around it.