1747984 Members
4827 Online
108756 Solutions
New Discussion юеВ

to clear syslogs

 
SOLVED
Go to solution
Veera.Rao
Frequent Advisor

to clear syslogs

how to clear the syslogs
which is stored in /var/adm/syslog/syslog/log.


and please tell me the command to clear the logs
11 REPLIES 11
Pete Randall
Outstanding Contributor

Re: to clear syslogs

Usually a reboot of the system causes the contents of syslog to be moved to OLDsyslog.log and syslog itself to be nulled out. If you wish to do that without rebooting, simply do:

mv /var/adm/syslog/syslog.log /var/adm/syslog/OLDsyslog.log
> /var/adm/syslog/syslog.log

That will save syslog and then null it out for you.


Pete

Pete
Veera.Rao
Frequent Advisor

Re: to clear syslogs

Hi,

can i do it without rebooting the server
Avinash20
Honored Contributor

Re: to clear syslogs

This could be done without reboot

Take backup of syslog.log if required
Trim it..
>/var/adm/syslog/syslog.log
"Light travels faster than sound. That's why some people appear bright until you hear them speak."
Veera.Rao
Frequent Advisor

Re: to clear syslogs

can you please tell me how to trim.


James R. Ferguson
Acclaimed Contributor
Solution

Re: to clear syslogs

Hi:

you *don't* want to move ('mv') the log file; rather you want to *copy* it and then truncate the original. This keeps logging working into the originally named file and not the renamed backup!

# cp /var/adm/syslog/syslog.log /var/adm/syslog/syslog.log.old
# cat /dev/null > /var/adm/syslog/syslog.log

Another way to do this is to do:

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

Regards!

...JRF...

Peter Nikitka
Honored Contributor

Re: to clear syslogs

Hi,

having trimmed a/the syslog-file(s), I recommend to inform a running syslogd about it via
kill -HUP `cat /var/run/syslog.pid`

You should get an entry in the new base syslog-file from syslog about a restart as well.

mfG Peter
The Universe is a pretty big place, it's bigger than anything anyone has ever dreamed of before. So if it's just us, seems like an awful waste of space, right? Jodie Foster in "Contact"
Patrick Wallek
Honored Contributor

Re: to clear syslogs

You can also run the syslogd stop/start script manually. Running this script will stop the syslog daemon, copy /var/adm/syslog/syslog.log to /var/adm/syslog/OLDsyslog.log, clean out syslog.log and then restart the syslog daemon.

After you run this, you can always rename OLDsyslog.log to something else if you desire.

# /sbin/init.d/syslogd stop

# /sbin/init.d/syslogd start
Veera.Rao
Frequent Advisor

Re: to clear syslogs

Hi,


Now my server is in production (LIVE).

if i stop and start the below script, is there any critical for running server.
kindly confirm and i will be very thankful to you all

# /sbin/init.d/syslogd stop
# /sbin/init.d/syslogd start
James R. Ferguson
Acclaimed Contributor

Re: to clear syslogs

hi (again):

> Now my server is in production (LIVE). if i stop and start the below script, is there any critical for running server?

No, this is absolutely safe. At most you might lose a few seconds of logged information while the 'syslogd' isn't active.

Regards!

...JRF...