Friday, March 14, 2008

How can I rotate my log files?

The default installations of Apache will set this up using the logrotate script. If you don't have this configured automatically or if you're using a non-standard installation (cPanel, Plesk, etc.) you can configure this in logrotate.
/etc/logrotate.d/httpd:

/path/to/httpd/logs/*log {
missingok
notifempty
sharedscripts
postrotate
/bin/kill -HUP `cat /path/to/httpd.pid 2>/dev/null` 2> /dev/null true endscript
}

Of course, update paths correctly and test appropriately.

No comments: