On Sat, May 30, 2009 at 08:40:08AM -0400, Jason Couture wrote:
Ive always just written a script to append the log file to a file name messages.MMDDYY.log and then delete the log file. and then created an init script to run it at boot time. That way everything is neatly sorted for later viewing, and i can delete the ones i no longer need manually.
logrotate does this automatically: /etc/logrotate.conf: # see "man logrotate" for details # rotate log files weekly weekly # keep 4 weeks worth of backlogs rotate 4 # create new (empty) log files after rotating old ones create # use date as a suffix of the rotated file dateext # uncomment this if you want your log files compressed #compress # RPM packages drop log rotation information into this directory include /etc/logrotate.d # no packages own wtmp and btmp -- we'll rotate them here /var/log/wtmp { monthly create 0664 root utmp minsize 1M rotate 1 } /var/log/btmp { missingok monthly create 0600 root utmp rotate 1 } # system-specific logs may be also be configured here. /etc/logrotate.d/syslog: /var/log/messages /var/log/secure /var/log/maillog /var/log/spooler /var/log/boot.log /var/log/cron { sharedscripts postrotate /bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true endscript } Resulting rotated log files: -rw-r-----. 1 root wheel 703684 2009-05-03 03:42 messages-20090503 -rw-r-----. 1 root wheel 814677 2009-05-10 11:42 messages-20090510 -rw-r-----. 1 root wheel 779478 2009-05-17 16:06 messages-20090517 -rw-r-----. 1 root wheel 721265 2009-05-24 15:03 messages-20090524 -rw-r-----. 1 root wheel 338888 2009-05-30 10:01 messages