How to avoid Apache server restart when using Logrotate

Stop Apache web server from restart when log files are rotated using Logrotate.

Use the copytruncate parameter to prevent Apache HTTP web server from restarting when log files are rotated. Logrotate will copy the log file and then truncate the log file instead of moving the file.

  1. Edit the logrotate configuration for Apache HTTP logs:

     $ nano /etc/logrotate.d/httpd
  2. Add the copytruncate parameter in the directive:

     /var/log/apache/*log {
        ...
        copytruncate
        ...
     }

    Logrotate configuration copytruncate parameter to prevent Apache from restarting

  3. Save the /etc/logrotate.d/httpd file changes.