Jan 292009
Since the Apache access logs grow with time, I like to rotate them once a month or so (for minor sites that don’t get much traffic). On Debian, you use logrotate
(I’ve written about setting it up here). On OpenSolaris, you use the logadm
command, with the actual rotation being specified in /etc/logadm.conf. When you look at that file, it warns you not to edit it by hand, which I found mildly amusing. Since you can make changes via the logadm
command itself, I figured I’d try that out.
For Apache log files in the usual place, /var/apache2/2.2/logs/access_log, reading the man pages for logadm gives
logadm -w apache -p 1m -C 24\
-t '/var/apache2/2.2/old_logs/access_log.%Y-%m'\
-a '/usr/apache2/2.2/bin/apachectl graceful'\
/var/apache2/2.2/logs/access_log
Testing with logadm -p now apache
seems to work just fine. I’ll know more about how reliable it is in a month.