1753483 Members
4143 Online
108794 Solutions
New Discussion юеВ

purging syslog.log

 
SOLVED
Go to solution
khilari
Regular Advisor

purging syslog.log

Hi people, well my syslog.log has become really big, so how do i go about purging it. Should i just rm it and the next entry in it will re generate it???.

Thanks.
5 REPLIES 5
Enrico P.
Honored Contributor

Re: purging syslog.log

Hi,
if you want to rotate the syslog files, you can restart the syslogd daemon:

/sbin/init.d/syslogd stop
/sbin/init.d/syslogd start

OLDsyslog.log will be remove, syslog.log will move to OLDsyslog.log.

Enrico
Robert-Jan Goossens
Honored Contributor

Re: purging syslog.log

Khilari,

Copy it first to save location
# cp /var/adm/syslog/syslog.log /tmp/syslog.old
# cp /dev/null /var/adm/syslog/syslog.log

Robert-Jan
Rick Garland
Honored Contributor

Re: purging syslog.log

The syslog.log is just 1 of the log files to be aware of - there are others that grow without bounds unless they are managed in some way.

One tool available on the http://gate.cs.utah.edu site is "logrotate"

You can input the names of the logfiles, how oftern to rotate, how many copies to keep, if you want to roatate on file size, etc.

SAM is avail to purge log files as well but this reuires manual intervention.
spex
Honored Contributor
Solution

Re: purging syslog.log

Khilari,

To prevent this from happening in the future, you could cron something like the following to run just before midnight:

#!/usr/bin/sh
set -u
DATE=`date +%Y%m%d`
###############################
# syslog
###############################
cd /var/adm/syslog
rm syslog.yester.log
cp syslog.log syslog.$DATE.log
ln -s syslog.$DATE.log syslog.yester.log
cat /dev/null > syslog.log
find /var/adm/syslog -name 'syslog.*.log' -mtime +90 -exec rm -f {} \;

This way, you have one syslog file per day, and syslog.yester.log is a symlink to yesterday's log, which is useful in scripts and command aliases (I have an alias which does a more on syslog.yester.log and syslog.log). If you find you have too many files or too much space is being taken up, you may scale back on the 90-day retention, or compress logsfiles.

PCS
MarkSyder
Honored Contributor

Re: purging syslog.log

Checking the contents of the syslog should be part of your daily sys admin duties. Once you have checked it, go into SAM -> routine tasks -> system log files and trim the syslog to its recommended size. In reality, this will create a trimmed file of the recommended size and empty the syslog.

Mark Syder (like the drink but spelt different)
The triumph of evil requires only that good men do nothing