Operating System - HP-UX
1827243 Members
2353 Online
109716 Solutions
New Discussion

routine task with /var/adm/syslog/syslog.log file

 
SOLVED
Go to solution
Ranjeet A.
Advisor

routine task with /var/adm/syslog/syslog.log file

Please tell me how to backup and trim /var/adm/syslog/syslog.log.(I am using Hp-Ux 11i v1). I am having SAM option and "cat /dev/null > /var/adm/syslog/syslog.log".
I cant even drop d log generated between the backup process and trimming. ie my backup copy + new syslog should make a "complete" log file.

regards
Ranjeet
8 REPLIES 8
James R. Ferguson
Acclaimed Contributor

Re: routine task with /var/adm/syslog/syslog.log file

Hi Ranjeet:

You can use the standard startup/stop script to accomplish this:

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

Doing the two-steps above, stops the 'syslogd' daemon and upon restarting it moves 'syslog' to 'OLDsyslog' just as happens after a reboot. Upon completion, you can do whatever you want with the 'OLDsyslog' file --- copy it, rename it, etc.

Regards!

...JRF...
Victor Fridyev
Honored Contributor

Re: routine task with /var/adm/syslog/syslog.log file

Hi,

If you don't want to stop syslogd, you can do the following:

cd /var/adm/syslog
gzip -c syslog > syslog.$(date +%a).gz
>syslog

By this way you will have compressed syslogs for last 7 days and each day you begins with a zero-size syslog

HTH
Entities are not to be multiplied beyond necessity - RTFM
Solution

Re: routine task with /var/adm/syslog/syslog.log file

Hi,

you could use logrotate tool:

Logrotate is designed to ease administration of systems that generate large numbers of log files. It allows automatic rotation, compression, removal, and mailing of log files. Each log file may be handled daily, weekly, monthly, or when it grows too large.

You can find it in:

http://hpux.connect.org.uk/hppd/hpux/Sysadmin/logrotate-2.5/

Regards.
Nguyen Anh Tien
Honored Contributor

Re: routine task with /var/adm/syslog/syslog.log file

You can backup it by tar command
#tar cvf /path/newfile /var/adm/syslog/syslog.log
Trim file:
#>/var/adm/syslog/syslog.log
But I highly recommend you use logrotate
http://hpux.connect.org.uk/hppd/hpux/Sysadmin/logrotate-2.5/
to rotate your log.
HTH
tienna
HP is simple
Ranjeet A.
Advisor

Re: routine task with /var/adm/syslog/syslog.log file

Hi All,
thanks for ur suggestions.I am very sorry to say that logs generated during these activities cannot be ignored ie during restarting the syslogd daemon or > /var/adm/syslog/syslog.log .Its a highly sensitive and mission critical env.

If I move the syslog file using mv command, will the system regenerate the log file for the next log.

ie:
#mv /var/adm/syslog/syslog.log ./syslog.$(date +%a).log

regards
Ranjeet

Mark Nieuwboer
Esteemed Contributor

Re: routine task with /var/adm/syslog/syslog.log file

Don't do that Ranjeet,
You never may move a file which is used by a process. If you do that the system is holding the space.
Then you see a diverence between bdf ond du -k.
what you can do is make a copy of the logfile and after that clear the logfile with >syslog.log
But better is to use logrotate tool becauce you have more logfiles on your system that must be trimmed once in a will.

grtz. Mark
Ranjeet A.
Advisor

Re: routine task with /var/adm/syslog/syslog.log file

Hi All,
Thanks a lot for ur kind support.
I am still working on a stategy on managing syslog file (without third party utilities)to meet the customer requirement.
So pls mail me ur valuable suggestion at ranjeet.ar@gmail.com

Regards
Ranjeet
Ranjeet A.
Advisor

Re: routine task with /var/adm/syslog/syslog.log file

.