Apache log rotation on Linux

A tool called logrotate can be used for rotating log files. It is a generic tool can can be configured to handle any log generated by any service.

The main configuration file of logrotate is /etc/logrotate.conf from where it picks up default setup.

It then reads service specific instructions from /etc/logrotate.d directory

The apache logrotate configuration is /etc/logrotate.d/httpd

/var/log/httpd/*log {
daily
rotate 7
compress
missingok
notifempty
sharedscripts
create 644 root root
postrotate
/sbin/service httpd reload > /dev/null 2>/dev/null || true
endscript
}

 

Leave a Reply

Your email address will not be published. Required fields are marked *