Technical article 127594

How do I automatically rotate my log files?

OpenServer 6.0.0OpenServer 5.0.7UnixWare 7.1.4

Written · Last revised

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/175156

As an example deployment, place the scripts in this download

perl-logrotate.pl
logrotate.conf
into  /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 information
logfile /var/adm/syslog
logfile /var/adm/log/osmlog

rotate-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.0
cp /var/adm/$ZIPLOG $LOGDIR/.
gunzip -f $LOGDIR/$ZIPLOG
egrep -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.zip

This technical article was submitted by Graham Unsworth of Hill Hire PLC (UK).

From the Xinuos technical article database, record 127594. Reproduced with permission. The original is at www.sco.com/ta/127594, which is reachable but blocked from search engines.

Next step

Need this fixed rather than explained?

Tell us the release, what the system runs and what it is doing. We will reply by email with what we would do next.

  • You deal with the people who do the work
  • No obligation, and no upgrade required before we will help
  • We tell you plainly if something is not worth doing

Send an enquiry

We reply by email. If a server is down, say so in the first line. You can also write to help@scoexpert.com.