syslog.log (75 Views)
Reply
Occasional Visitor
dan burns
Posts: 1
Registered: ‎05-31-2000
Message 1 of 6 (75 Views)

syslog.log

Looking for a script that will save /var/adm/syslog/syslog.log every week to a new file called syslog.120800(?). I do not like just having one log and one old log...Has anyone done anything like this before?

Thanks
Please use plain text.
Trusted Contributor
Maureen Gunkel
Posts: 101
Registered: ‎09-05-2000
Message 2 of 6 (75 Views)

Re: syslog.log

Dan,

#!/bin/sh

dt=`date '+%m%d%y'`
cp /var/adm/syslog/syslog.log syslog.$dt

or maybe mv, but I always prefer to copy rather than move.

You would then put an entry in your crontab to run it once a week, on the day of the week and time of the day to be run. For example, to run it on Sundays at 2am --

0 2 * * 0 filenamewithpathname > /dev/null 2>&1
HTH
Mo
No matter where you go, there you are.
Please use plain text.
Honored Contributor
Darrel Louis
Posts: 856
Registered: ‎11-27-2000
Message 3 of 6 (75 Views)

Re: syslog.log

Dan,

Here you have a good url where you can find handy information.

ftp://contrib:9unsupp8@hprc.external.hp.com/sysadmin/cronjobs

Have Fun
Please use plain text.
Advisor
Matjaz Obstetar
Posts: 15
Registered: ‎12-01-1999
Message 4 of 6 (75 Views)

Re: syslog.log

Dan,

Maureens solution is good, but on reboot or when you restart syslog deamon syslog.log will move to syslog.old. If you want to have syslog.log in Maureens format you should put an entry in /sbin/init.d/syslogd

dt=`date '+%m%d%y'`

and change the line
mv /var/adm/syslog/syslog.log /var/adm/syslog/OLDsyslog.log

to

mv /var/adm/syslog/syslog.log /var/adm/syslog/syslog.$dt

Regards,
Matjaz

To sem jaz
Please use plain text.
Honored Contributor
Carlos Fernandez Riera
Posts: 1,172
Registered: ‎09-16-1998
Message 5 of 6 (75 Views)

Re: syslog.log

Hi:

After mv syslog.log file you must restart syslogd daemon.

Syslogd will keep on writing on your syslog.log moved file because dont close his file descriptor.


So send HUP signal to syslogd PID to force reconfiguration of syslogd.

kill -HUP `cat /var/run/syslog.pid`

See man syslogd

unsupported
Please use plain text.
Honored Contributor
federico_3
Posts: 499
Registered: ‎07-10-2000
Message 6 of 6 (75 Views)

Re: syslog.log

If you perform the reboot every week ( the best thing for me ...) you could create a script /sbin/init.d/copy_syslog and two links
/sbin/rc3.d/Sxxxcopy_syslog -> /sbin/init.d/copy_syslog
/sbin/rc2.d/Kxxxcopy_syslog -> /sbin/init.d/copy_syslog .

The script copy_syslog in the stop section will have:
cat /var/adm/syslog/syslog.log | grep -v bootpd | grep -v repeated > DIR/syslog.`date +%y%m%d `

federico
Please use plain text.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation