1832857 Members
3137 Online
110048 Solutions
New Discussion

Re: Trimming log files

 
SOLVED
Go to solution
Sanjiv Sharma_1
Honored Contributor

Trimming log files

Hi,

What is the best method of monitoring the log files in the HP-UX System and trimming them?

Do you have any script which trimmes all the log files when the /var fs is 90% full?

Thanks,
Everything is possible
9 REPLIES 9
john korterman
Honored Contributor
Solution

Re: Trimming log files

Hi,
SAM has a good facility for trimming logfiles:
SAM -> Routine tasks -> System Log Files
where you can manually select files for trimming.

There is at least one script for trimming a logfile in this thread:
http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x836cc1c4ceddd61190050090279cd0f9,00.html

But I would not recommend just to trim the log files if they are filling up; read them and find out why.

regards,
John K.
it would be nice if you always got a second chance
Vicente Sanchez_3
Respected Contributor

Re: Trimming log files

Hello,

Trim files is one thing you have to do when /var is nn% full, but also consider to check other things like adm/crash, tmp or adm/sw/save directories.

HTH, Vicente.
Christian Gebhardt
Honored Contributor

Re: Trimming log files

Hi

We uses the tool "prune", you can easily configure files to prune. Limits can be given in lines, or bytes.

Source code at

http://wuarchive.wustl.edu/languages/c/unix-c/sysadmin/

Chris
Balaji N
Honored Contributor

Re: Trimming log files

logrotate is the utility which does this on linux boxes. saw that there is a port available for the same on hpux.
see if this helps.

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

-balaji
Its Always Important To Know, What People Think Of You. Then, Of Course, You Surprise Them By Giving More.
Pete Randall
Outstanding Contributor

Re: Trimming log files

I personally use SAM to trim the various log files, but I've rarely seen log s have that much influence on space in /var. You need to take a harder look at what's using up your /var space. Run "du -sk /var/*", then look at the largest directories in more detail. Use the cleanup command to commit superceded patches, freeing up space in /var/adm. Drill down into lower level directories using the "du -sk" command and find out where your problems really lie, then address them.


Pete

Pete
John Meissner
Esteemed Contributor

Re: Trimming log files

I use SAM to do this. it's located under Routine Tasks. SAM will show you the %full the size and the recommended size of the logs. just highlight the logs you want to trim and go to actions>trim>trim to recommended sizes.

Very quick

All paths lead to destiny
twang
Honored Contributor

Re: Trimming log files

I don't think we should auto-trim logfiles. I would suggest we should periodically check these logfiles(routine task of a system administrator) and trim them then. You may use following command:
tail - >tmplog; mv tmplog >
Shannon Petry
Honored Contributor

Re: Trimming log files

twang,

What you suggest to do will not work! The system log is not opened by a filehandle. Your idea would work in a different approach.

tail -1000 /var/adm/syslog/syslog.log >/tmp/tmpsyslog.log
cat /tmp/tmpsyslog.log > /var/adm/syslog/syslog.log


Please try what you suggested and see what happens. Dont worry, unless your /var is full it will not crash the system.

It's a good idea to test suggestions before posting them unless your sure they work ;)

Regards,
Shannon
Microsoft. When do you want a virus today?
Jordan Bean
Honored Contributor

Re: Trimming log files


We daily run this rather simple posix shell script to archive our syslogs (not rotate) for up to three months. It assumes that the syslogd configuration is in /etc/syslog.conf and that all active logs are in /var/adm/syslog. A similar procedure can be used to archive Apache logs.

The basic method is to move aside all the current, open logs, create new empty files, and send SIGHUP to syslogd to close the current files and open the new ones.