Thanks a lot to all the senders:
Vienzenz Esser
Richard N. Frank
Franz Fischer
Lucio Chiappetti
Kevin Reardon
Sandro Valencia
There was a lot of usefull hints, which I try to summarize here.
The original question had 2 parts, first experiences which logfiles you
would cleanup and where they are located? And the second part is there some
available procedure to perform this task?
The sugestions were to cleanup the following files
(/usr/adm/syslog.dated this is done automaticly by crontab job)
/usr/adm/binary.errlog
/usr/adm/wtmp
/var/X11/xdm/xdm-errors
httpd daemon log the location depends of the
installation
I still want to learn a bit more about logfiles on DU, when performing a
search (find -name "*log*") for example what are the *_softlinks.log, and so
on.
I mostly received answers on the second part. There was a lot of good idees,
like for example saving logs in compressed format, and so on. I decided to
make my own tool, not because mine would be better but I had some contraints
like application restart requirements, and wanted to have a clear view of
the logfiles maintained. The following example is not fully tested but gives
an idee of what I will be using (you have to configure your own logs):
#!/bin/perl
# --------------------------------------------------------------
# Filename: cleanup.pl
# Creation Date: 13.01.1999
# Author: F.Maurer, Die schweizerische Post
#
# Abstract: This program cleanup logfiles on DU
#
# Remarque: 1. We assume that this procedure runs once a week.
# 2. Be carefull by deleting logfiles, they loose
their
# attributes. This may interfer with the
application
#
# Parameters none
# --------------------------------------------------------------
# Variables definitions
$da = 5; # default action
$dv = 4; # default number of versions to keep
# layout: filename,action(1=sav,2=del,4=crea),nbr of version,stop,start
_at_lol = (
["/usr/var/adm/messages",$da,$dv,'',''],
["/usr/var/adm/event_file",$da,$dv,'ncl disable event dispatcher sink
\*','ncl enable event dispatcher sink \*'],
["/usr/var/adm/backup.log",$da,$dv,'',''],
["/usr/var/adm/mta_events.log",$da,$dv,'',''],
["/usr/var/adm/wtmp",$da,$dv,'',''],
["/usr/var/adm/binary.errlog",$da,$dv,'',''],
["/usr/var/adm/smtp_gateway_events.log",$da,$dv,'',''],
["/usr/internet/ns-home/httpd-IAS-Public/logs/access",$da,$dv,'',''],
["/usr/internet/ns-home/httpd-IAS-Public/logs/errors",$da,$dv,'',''],
["/usr/users/helpdesk/filter-log",3,1,'',''],
["/var/opt/dtadvfs/advfs_gui.log",$da,2,'',''],
["/var/opt/advfsd/logs/advfsd",$da,2,'',''],
["/usr/adm/decedi/logs/db_errors.log",$da,$dv,'',''],
["/usr/adm/decedi/logs/decedi_errors.log",$da,$dv,'',''],
["/usr/adm/decedi/logs/decedi_opcom.log",$da,$dv,'/usr/sbin/decedi_stop','/u
sr/sbin/decedi_start']
);
# --------------------------------------------------------------
# Program start
date();
if ($wday ne "1") {exit;}
for $i (0..$#lol) {
$logfile = _at_lol->[$i][0];
$action = _at_lol->[$i][1];
$version = _at_lol->[$i][2];
$stop = _at_lol->[$i][3];
$start = _at_lol->[$i][4];
# perform cleanup as required
log_save() if ($action == 1 or 3 or 5 or 7);
log_delete() if ($action == 2 or 3 or 6 or 7);
log_create() if ($action == 4 or 5 or 7);
# purge old logfiles
log_purge() if ($version > 0);
# restart application
if ($start gt "" and $stop gt "") {
system "$stop";
system "$start";
}
}
sub log_save {
date();
system "cp $logfile $logfile.$date" if -e $logfile;
}
sub log_delete {
system "rm $logfile" if -e $logfile;
}
sub log_create {
system "cp /dev/null $logfile";
}
sub log_purge {
_at_files = glob("$logfile.*");
for $j (0.._at_files-($version+1)) {
print "delete file: -> $files[$j]\n";
system ("rm $files[$j]");
}
}
sub date {
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time);
$date=sprintf "%04d%02d%02d",$year+1900,$mon+1,$mday;
}
__END__
Following are the examples I received:
from Richard N. Frank:
# ***********************************************************************
# new_last.com 15. jan. 1997 rnf
#
last > /home/rootrnf/audit/$(date +"%d%m%y")last.log
cat /home/rootrnf/audit/$(date +"%d%m%y")last.log
cd /var/adm
q=1
while [ "$q" -lt "10" ]
do
fn=wtmp.bak$q
echo $fn
if test -f wtmp.bak$q
then
echo "wtmp.bak"$q" exists"
else
mv wtmp wtmp.bak"$q"
let q=12
fi
let q=q+1
done
if [ "$q" -eq "11" ]
then
echo ""
echo " ***** There are too many wtmp.bak files..."
echo " ***** do some file maintenance. **********"
echo ""
fi
touch wtmp
ls -la wtmp.*
echo ""
echo " ... done "
from Franz G. Fischer:
<<periodic examples>>
from Kevin Reardon:
********** START roll.logs.sh **********
#!/usr/local/bin/bash
months=([0]=Dec Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov)
TARCMD="/freeware/bin/tar"
GZIPCMD="/usr/bin/gzip -9"
TARFLAGS="-cf"
ADM="/var/adm"
SYSLOG_PATH="$ADM/syslog.dated"
OUTPUT_PATH="$ADM/archived.syslogs"
MONTH=`date +'%m'`
#trim off leading zero, if any
MONTH=${MONTH#0}
LASTMONTH=$(($MONTH-1))
LASTMONTH_NAME=${months[$LASTMONTH]}
YEAR=`date +'%Y'`
if [ "$MONTH" = "1" ]; then
YEAR=$(($YEAR-1))
fi
OUTPUT_FILE="$OUTPUT_PATH/$LASTMONTH_NAME.$YEAR.syslogs.tar"
$TARCMD $TARFLAGS $OUTPUT_FILE $SYSLOG_PATH/*$LASTMONTH_NAME*
$GZIPCMD $OUTPUT_FILE
# ********** END roll.logs.sh **********
and from Sandro Valencia:
****************************************************
MES=`/usr/bin/date "+%b"`
MESL=`/usr/bin/date "+%m"`
ANO=`/usr/bin/date "+%Y"`
# El sleep permite que la depuracion del log se realice a partir del mes
siguiente
sleep 90
################################
# Actualizacion del daemon.log #
################################
grep "^${MES}" /var/adm/syslog/daemon.log >
/var/adm/syslog/daemon.log.${ANO}${MESL}
grep -v "^${MES}" /var/adm/syslog/daemon.log > /tmp/actual.daemon.log
> /var/adm/syslog/daemon.log
cat /tmp/actual.daemon.log >> /var/adm/syslog/daemon.log
rm /tmp/actual.daemon.log
##############################
# Actualizacion del mail.log #
##############################
grep "^${MES}" /var/adm/syslog/mail.log >
/var/adm/syslog/mail.log.${ANO}${MESL}
grep -v "^${MES}" /var/adm/syslog/mail.log > /tmp/actual.mail.log
> /var/adm/syslog/mail.log
cat /tmp/actual.mail.log >> /var/adm/syslog/mail.log
rm /tmp/actual.mail.log
***********************************************************
__________________________________________________
Felix Maurer
Die Schweizerische Post Tel: +41-31-338 98 49
Informatik POST Fax: +41-31-338 98 80
Messaging Management
Webergutstrasse 12 Mailto:maurerf_at_post.ch
CH-3030 Bern
http://www.post.ch
__________________________________________________
Received on Thu Jan 14 1999 - 16:21:36 NZDT