Problem
How do I automatically rotate my syslog log files?
Solution
The following Open Source utility can be useful for rotating log files:
http://freshmeat.net/projects/perl-logrotate/releases/175156As an example deployment, place the scripts in this download
perl-logrotate.pl
logrotate.confinto /usr/local/bin/logrotate and make sure that perl-logrotate.pl
is made executable.The log files defined in logrotate.conf need to be changed.
Here is an example for UnixWare7 but can easily be changed for other SCO Unix log files.
-----## Configuration for logrotate
# Please read perl-logrotate.pl for more informationlogfile /var/adm/syslog
logfile /var/adm/log/osmlogrotate-time 23 hours keep-files 365 compress yes status-file /var/adm/logrotate.status dryrun no
-----We can then run /usr/local/bin/logrotate/perl-logrotate.pl and the results can be seen in the logfile directory (above) and in /var/adm/logrotate.status.
If you would like to examine the archived syslog, the following script may be useful:
-----############################################################
# Script that extracts information from the system log. #
# The daily log is created using logrotate. #
############################################################DAY=`date +%d%m%y`
SYSTEM=`uname -n`
MAIL_REC=user.name@domainname.co.uk
LOGDIR=/var/adm/log
ZIPLOG=syslog.0.gz
LOG=syslog.0cp /var/adm/$ZIPLOG $LOGDIR/.
gunzip -f $LOGDIR/$ZIPLOGegrep -i 'password|disconnect|failure|fatal' $LOGDIR/$LOG> $LOGDIR/eventlog#mail -s "`uname -n` Event Log" $MAIL_REC< $LOGDIR/eventlog-----We can change the MAIL_REC to the name of choice and uncomment the last line to have the results emailed to your inbox, assuming that email is configured and the two scripts could be placed in your cron to be ran daily.
See also
This can be downloaded from:ftp://ftpput.sco.com/tmp/support/utils/logrotate/logrotate.zipThis technical article was submitted by Graham Unsworth of Hill Hire PLC (UK).