On Wed, Jan 23, 2008 at 08:25:10PM -0700, Jon Fullmer wrote:
> I'm interested to hear what other BLFS users use to rotate their
> syslogs.
Mine is a homebrew. I replaced /var/log by /var/log/syslog everywhere
in /etc/syslog.conf . Then I run a daily cron job that keeps a week's
worth of archives of /var/log/syslog in subdirectories of
/var/log/syslog-old . I've attached the script; YMMV of course.
Jeremy Henty
#!/bin/sh
# Rotate the system logs.
# NB: we move the log directory *first*. The syslogd's file handles
# are still valid so it still logs to the old files. Then we create a
# fresh log directory and "kill -HUP" the syslogd. This tells it to
# reopen its log files, which starts fresh logs in the new log
# directory.
date="$( date '+%Y-%m-%d_%H-%M-%S' )" # name for archived log directory
( cd /var/log/ &&
mkdir -p -- syslog-old &&
mv syslog "syslog-old/${date}" && {
( cd syslog-old &&
rm -rf -- $( ls -1At | tail +8 ) )
mkdir -p -- syslog
} ) &&
kill -HUP "$( cat /var/run/syslogd.pid )"
--
http://linuxfromscratch.org/mailman/listinfo/blfs-support
FAQ: http://www.linuxfromscratch.org/blfs/faq.html
Unsubscribe: See the above information page