- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: How to trim log file with out restarting syslo...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-24-2010 07:01 AM
тАО06-24-2010 07:01 AM
How to trim log file with out restarting syslogd
I would like to trim one log file.
# /var/adm/syslog > ll
-rw-r--r-- 1 root sys 254125900 Jun 24 09:58 user_log
It's size is around 254MB, now I would like to trim to 1 or 2MB with out restarting syslogd.
Is it possible.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-24-2010 07:44 AM
тАО06-24-2010 07:44 AM
Re: How to trim log file with out restarting syslogd
Discussion on a similar requirement -
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1033864
http://forums13.itrc.hp.com/service/forums/questionanswer.do?threadId=1053445
Hope this helps.
Regards,
Murali
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-24-2010 08:02 AM
тАО06-24-2010 08:02 AM
Re: How to trim log file with out restarting syslogd
you can trim upto a %
there are many more options in it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-24-2010 08:03 AM
тАО06-24-2010 08:03 AM
Re: How to trim log file with out restarting syslogd
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-24-2010 08:07 AM
тАО06-24-2010 08:07 AM
Re: How to trim log file with out restarting syslogd
cp /var/adm/syslog/syslog.log /var/adm/syslog/syslog.copy
tail -2000 /var/adm/syslog/syslog.copy > /var/adm/syslog/syslog.log
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-24-2010 08:27 AM
тАО06-24-2010 08:27 AM
Re: How to trim log file with out restarting syslogd
The methodology shown by Pete will work. The key requirement to not restarting a logging daemon is *not* to change the inode number associated with the process's file handle for the file. Hence, you cannot simply 'mv' the log to another name and create a file of the original name in its place.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-24-2010 10:13 AM
тАО06-24-2010 10:13 AM
Re: How to trim log file with out restarting syslogd
Triming a log file :save as trimlog with execute permission.
#! /bin/sh
# trimlog
filesize=`cat $1|wc -l`
trim=`expr $filesize - $2`
if [ $trim -gt 0 ]
then
sed "1,$trim d" $1 > /tmp/$1
mv /tmp/$1 $1
echo $1 trimmed by $trim lines
fi
sysntax : usage
#cat oracle_listener.log |wc -l
20000
for 50% reduction divide it by 2...
# trimlog oracle_listener.log 10000
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-24-2010 12:15 PM
тАО06-24-2010 12:15 PM
Re: How to trim log file with out restarting syslogd
I like Pete's method also. sam might do a hangup restart on the syslod daemon. Not sure though.
JRF points out quite correctly that if you want the space back, trimming it with a script may be a problem. The space might not be released until the file handle is released.
I would try Pete's method and see what bdf and df -kh show after the fact.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-24-2010 12:34 PM
тАО06-24-2010 12:34 PM
Re: How to trim log file with out restarting syslogd
> SEP: JRF points out quite correctly that if you want the space back, trimming it with a script may be a problem. The space might not be released until the file handle is released.
There is no problem with the release of space. The method uses 'truncate()' to reduce the length of the file followed by a 'seek()' to align the file offset. Thus, the disk space used by the in-use file is reduced.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-25-2010 03:20 AM
тАО06-25-2010 03:20 AM
Re: How to trim log file with out restarting syslogd
Sorry,
Pete
Pete