Where to insert a script to generate a report from auth.log just before rotating it?
Adam Funk
a24061 at yahoo.com
Wed Sep 20 15:56:42 UTC 2006
A while back on another list I was advised that auth.log (and syslog
and a few others) are rotated by /etc/cron.weekly/sysklogd. I'm now
interested in running a Perl program to generate a report from
auth.log just before each rotation.
Should I just insert my report-generating command into that file at
one of the points marked below?
Thanks,
Adam
#! /bin/sh
#[comments snipped]
test -x /usr/sbin/syslogd-listfiles || exit 0
test -x /sbin/syslogd || exit 0
test -f /usr/share/sysklogd/dummy || exit 0
set -e
cd /var/log
# insert the following? <-------
/path/to/my_report auth.log |mail -s 'auth.log report' root
for LOG in `syslogd-listfiles --weekly`
do
if [ -s $LOG ]; then
# or is it safer to do it here? <-------
if [ "$LOG" == "auth.log ]; then
/path/to/my_report auth.log |mail -s 'auth.log report' root
fi
savelog -g adm -m 640 -u root -c 4 $LOG >/dev/null
fi
done
# Restart syslogd
#
/etc/init.d/sysklogd reload-or-restart > /dev/null
More information about the ubuntu-users
mailing list