rotate log files with logadm

To rotate logs on a Solaris system you have to configure logadm to do it.

This is a small example on how it could look like for lighttpd.

Execute the two following statements to create two log entries

logadm -w /var/lighttpd/1.4/logs/access.log -p 1d -C 8 -a 'pkill -HUP lighttpd; true'
logadm -w /var/lighttpd/1.4/logs/error.log -p 1d -C 8 -a 'pkill -HUP lighttpd; true'

After that, there should be two new entries in /etc/logadm.conf with all parameters you gave to logadm. The parameters mean, that the logs will be rotated once a day and 8 old logfiles will be stored. With every rotation lighttpd will be reloaded to use the new empty log file. For more parameters read the man page of logadm. there are also some nice examples at the bottom.

To try it out and see if it runs, create enough log entries and then call logadm with the logfile. In this case it would be

logadm /var/lighttpd/1.4/logs/access.log
logadm /var/lighttpd/1.4/logs/error.log

After that, it should have created new log files and reloaded lighttpd.