1846625 Members
1908 Online
110256 Solutions
New Discussion

syslog

 
SOLVED
Go to solution
Michael_33
Regular Advisor

syslog

I saw the syslog.log keeps 4 day info. and
after 4 days, it will be moved to OLDsyslog.log
now I want the syslog.log keeps only one day
info. how can I do?

Thanks!
9 REPLIES 9
Michael_33
Regular Advisor

Re: syslog

maybe needs a script?
Kurt Beyers.
Honored Contributor

Re: syslog

There wasn't a system reboot as this will cause a copy of syslog.log to OLDsyslog.log and create a new syslog file?

Kurt
Michael_33
Regular Advisor

Re: syslog

You are right!
but I want the syslog.log keeps only one day
info. the other will keep in OLDsyslog.log.
how can I do?
Michael_33
Regular Advisor

Re: syslog

You are right!
but I want the syslog.log keeps only one day
info. the other will keep in OLDsyslog.log.
how can I do?
Michael_33
Regular Advisor

Re: syslog

You are right!
but I want the syslog.log keeps only one day
info. the other will keep in OLDsyslog.log.
how can I do?
Michael_33
Regular Advisor

Re: syslog

You are right!
but I want the syslog.log keeps only one day
info. the other will keep in OLDsyslog.log.
how can I do?
Hartmut Lang
Trusted Contributor

Re: syslog

Peter Kloetgen
Esteemed Contributor

Re: syslog

Hi Michael,

you should just write a simple script, which can do this for you:

cp /var/adm/syslog/syslog.log /var/adm/syslog/syslog.old

> /var/adm/syslog/syslog.log

The first line makes a copy of your existing logfile, the second line trims the syslog.log file to zero. Put this into a cron job, which you run each day on midnight. That should do it for you!

Allways stay on the bright side of life!

Peter

I'm learning here as well as helping
Sukant Naik
Trusted Contributor
Solution

Re: syslog

Hi Michael,

First create a shell script
flush_syslog as shown below.

#!/usr/bin/ksh
cp /var/adm/syslog/syslog.log /var/adm/syslog/syslog.`date +%d%b%y`
>/var/adm/syslog/syslog.log

This above script will create a syslog file for each day with the time stamp.

And later schedule a cronjob for root as below which is executed everyday.

59 23 * * * sh /usr/sbin/flush_syslog

-Sukant
Who dares he wins