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


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?

Trusted Contributor
Posts: 101
Registered: ‎09-05-2000
Message 2 of 6 (91 Views)

Re: syslog.log



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
No matter where you go, there you are.
Honored Contributor
Posts: 856
Registered: ‎11-27-2000
Message 3 of 6 (91 Views)

Re: syslog.log


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

Have Fun
Posts: 15
Registered: ‎12-01-1999
Message 4 of 6 (91 Views)

Re: syslog.log


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


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


To sem jaz
Honored Contributor
Posts: 1,172
Registered: ‎09-16-1998
Message 5 of 6 (91 Views)

Re: syslog.log


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/`

See man syslogd

Honored Contributor
Posts: 499
Registered: ‎07-10-2000
Message 6 of 6 (91 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 `

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.