Operating System - HP-UX
1854699 Members
10241 Online
104102 Solutions
New Discussion

can i trim my pkg.sh.log when the pkg is running?

 
SOLVED
Go to solution
leelangco_1
Frequent Advisor

can i trim my pkg.sh.log when the pkg is running?

hi,i found my / is increasing these days,and it is beacause that the size of pkg.sh.log is increasing(the application is logging something to it time to time).i have checked the itrc forums for solutions,and i think the best way is to trim the pkg.sh.log periodicly. now what i am not sure is that when the pkg is running,can i trim the log file or not ?

i want to do followings:

cp pkg.sh.log /tmp/pkg.sh.log.bak(backup it)

vi pkg.sh.log (trim it)

is it feasible? thank you!
3 REPLIES 3
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: can i trim my pkg.sh.log when the pkg is running?

The log file can be trimmed but:
1) Don't copy it to /tmp; /tmp is only intended for directly OS-related temporary files; /var/tmp is the normal location for application-related temporary files unless overridden by the TMPDIR variable.

2) Don't use vi; use Perl, sed, or awk to trim the file so that a scripted solution (possibly a cron'ed task) is possible.
If it ain't broke, I can fix that.
leelangco_1
Frequent Advisor

Re: can i trim my pkg.sh.log when the pkg is running?

why not use vi ?
is there any disadvantage?
i donot to make it a cronjob but manually edit it.
thank you!
A. Clay Stephenson
Acclaimed Contributor

Re: can i trim my pkg.sh.log when the pkg is running?

Because it is the goal of every administrator to do as little as possible. I would much rather have a smart script that looks for unusual messages and finding none then trims the log periodically. If it finds something interesting then it should alert you and take no action on the file itself.

Your systems should be self-monitoring and as automated as possible so that your time can be used for more productive tasks. The last thing I want to do is spend a lot of time manually editing a bunch of log files that essentially say "all is well".
If it ain't broke, I can fix that.