1748180 Members
4138 Online
108759 Solutions
New Discussion юеВ

Re: syslog.log

 
dan burns
New Member

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
5 REPLIES 5
Maureen Gunkel
Trusted Contributor

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.
Darrel Louis
Honored Contributor

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
Matjaz Obstetar
Advisor

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
Carlos Fernandez Riera
Honored Contributor

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
federico_3
Honored Contributor

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