Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

rotate syslog

Status
Not open for further replies.

pichi

Programmer
Nov 12, 2000
156
EC
hi everybody do you know how can i rotate my syslog?, it's getting to large!!
need help
thanks in advance,,
by the way how can i see what is the installed AIX version??
thanks again

pichi
 
Command (oslevel) will give you the aix level.

as for rotate your syslog I dont know what you mean.

you should be able to clear the log file out.

> /xxx/xxx were x is replace with path.

like this
> /var/adm/wtmp this well clean out wtmp file.
I hope this helps you if this is what you are looking for.
 
what i am trying to say is this, for example the
/var/log/syslog, i want to rotate so i don't need to erase or clear it, so if there is a script in the AIX OS, that permits me to do this:
the actual syslog
syslog
the olds ones
syslog.0
syslog.1
 
Why don't you create a script to run from the crontab to do it for you on a regular basis, say once a week/month? That way you could have a bit better control as well, and perhaps even introduce some date-stamping of the backup files as well, plus deleting them after a set time period.

Example script below , line 1 and 4 isn't correct, but it will give you an idea how to do it.


DATE=`date %dd%mm%yy` (do a man date to see the correct fmt)
cp /var/log/syslog /var/log/syslog$DATE
>/var/log/syslog
find /var/log/syslog* -mtime 30 exec rm{}; (do a man find)


Hope this will help you
Chris IBM Certified Specialist - MQSeries
 
How to Clear accounting information file /var/adm/wtmp:
Use following command.
"/usr/sbin/acct/nulladm /var/adm/wtmp"
 
Here is a syslog rotation script you could add to the cron.

Cheers



#!/bin/ksh
#
# Rotate syslogs every Sunday at 23:59pm
#
# Paul Sharpe
#
#--------------------------------------------------------------------#
# Rotating syslog. #
#--------------------------------------------------------------------#

LOGDIR=/var/log
LOG=syslog
if test -d $LOGDIR
then
cd $LOGDIR
if test -s $LOG
then
test -f $LOG.3 && mv $LOG.3 $LOG.4
test -f $LOG.2 && mv $LOG.2 $LOG.3
test -f $LOG.1 && mv $LOG.1 $LOG.2
test -f $LOG.0 && mv $LOG.0 $LOG.1
mv $LOG $LOG.0
cp /dev/null $LOG
chmod 644 $LOG
sleep 40
fi
fi

# Refresh syslogd
kill -HUP `cat /etc/syslog.pid`

PSD
IBM Certified Specialist - AIX V4.3 Systems Support
IBM Certified Specialist - AIX V4 HACMP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top