1834935 Members
2188 Online
110071 Solutions
New Discussion

shrinking log files

 
SOLVED
Go to solution
Chris Fadrowski
Super Advisor

shrinking log files

Is there a way to shrink down log files such as swagent.log ? I am looking for a way to clear out some of them and make smaller. Especially the ones that are getting very large to save some disk space.
7 REPLIES 7
Steven E. Protter
Exalted Contributor

Re: shrinking log files

swagent log can be shrunk with cron.

We also run this script once a month:

cp swagentd.log > /backups/sdux
> swagentd.log

That nulls it out.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Chris Fadrowski
Super Advisor

Re: shrinking log files

I would like to be able to do this manually. I tryed your 2nd idea and it doesn't work for me. I created a file to copy to. I guess i am not understanding it correctly.
Jeff Schussele
Honored Contributor
Solution

Re: shrinking log files

Hi Chris,

SAM has a built-in log trimming utility.
Go to:

sam & -> Routine Tasks -> System Log Files -> highlight the log file (sw*.log are there already) -> Actions -> Trim -> select trim method.

You could then capture SAMs method/commands from the sam log & build a script to run from cron.

HTH,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Umapathy S
Honored Contributor

Re: shrinking log files

Chris,
Try this out. This empties the swagentd.log.
As far, trimming down, Jeff's suggestion is easy and good one.
cat /dev/null > swagentd.log.

HTH,
Umapathy
Arise Awake and Stop NOT till the goal is Reached!
Steven E. Protter
Exalted Contributor

Re: shrinking log files

More specific:

/sbin/init.d/swagentd stop
> /var/adm/sw/swagentd.log
/sbin/init.d/swagentd start

The earlier command porbably failed because the daemon was running.

SEP

Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
GK_5
Regular Advisor

Re: shrinking log files

Use SAM to trim to system log files. Start SAM - Routine Tasks - System Log Files - Highlight the log file - Actions - Trim and select the desired option.

-GK-
IT is great!
Alzhy
Honored Contributor

Re: shrinking log files

I do not know if this is true on HPUX environments but on other "Unices" - I take extra care when trimming log files -- specially those active (or open) ones.

What I usually do is in the log rotater script, I have a routine there that once the current large log is copied to a different location, I do a cp /dev/null /var/adm/someactive.log.

The reason is that sometimes, even if you have deleted that large active log file on a filesystem, it does not free up the space occupied by the deleted file...

Hakuna Matata.