- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Trimming log files
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
Forums
Discussions
Discussions
Discussions
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
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
01-30-2003 08:19 AM
01-30-2003 08:19 AM
Trimming log files
I am using the following command:
tail -5000 log > log.old and then the idea is to zero the original log file.
But the tail command takes only the last 365 lines and the same thing happens with the tail -n option. Is there any limitation for the number of lines with the tail command or can any one tell me another method to trim the file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2003 08:23 AM
01-30-2003 08:23 AM
Re: Trimming log files
"Tails relative to end-of-file are stored in a 20-Kbyte buffer, and
thus are limited in length."
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2003 08:25 AM
01-30-2003 08:25 AM
Re: Trimming log files
I found this with man tail:
Tails relative to end-of-file are stored in a 20-Kbyte buffer, and
thus are limited in length. Therefore, be wary of the results when
piping output from other commands into tail.
Tom
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2003 08:25 AM
01-30-2003 08:25 AM
Re: Trimming log files
As Pete mentioned, there is a buffer limit for 'tail'. Take a look at these two threads. I'm pretty sure there are some scripts in there that will take care of log files:
http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x026250011d20d6118ff40090279cd0f9,00.html
http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x836cc1c4ceddd61190050090279cd0f9,00.html
JP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2003 08:26 AM
01-30-2003 08:26 AM
Re: Trimming log files
Yes, 'tail' has definite buffer limitations. The better choice is to use 'sed' to chop. Calculate from where you want to delete, for instance with 'wc -l filename' and then do:
# sed -e '1000,$!d' infile > outfile
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2003 08:49 AM
01-30-2003 08:49 AM
Re: Trimming log files
Sorry, I didn't quit finish the above. I suggested using 'wc -l' to deduce the size of your logfile and then inferred computing some line-number to which you want to trim. The example I gave was:
# sed -e '1000,$!d' infile > outfile
Obviously, that's OK for static values. To use a calculated line number, call it "N", change the above to:
# N=1000 #...or whatever, however derived...
# sed -e "$N,$"!d infile > outfile
...Note the use of double quotes to allow shell expansion.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2003 09:45 AM
01-30-2003 09:45 AM
Re: Trimming log files
To just zero the file do
#> /var/adm/cron/log
Note that standard log files can also be trimmed using SAM as follows:
sam -> Routine Tasks -> System Log Files -> highlight /var/adm/cron/log -> Actions -> Trim
And there are several trim options available. You can also set a unique size to key the actions on.
HTH,
Jeff