- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Edit log flie that is in use?
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-21-2001 10:23 AM
тАО06-21-2001 10:23 AM
Consider /var/adm/syslog/mail.log on a busy mail relay, please. It is being appended constantly by sendmail via syslogd. Now let's say this file is enormous and contains entries back through late April. Is there any way that you know of that would allow me to amputate all entries prior to June "on the fly" without either
1. Temporarily stopping syslogd (where best-case is mail log messages get lost and worst-case is sendmail pukes and dies), or
2. Temporarily stopping sendmail (which pisses off users because their joke-of-the-day email is ten minutes late)?
Thanks in advance,
Jim
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-21-2001 10:31 AM
тАО06-21-2001 10:31 AM
Re: Edit log flie that is in use?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-21-2001 10:48 AM
тАО06-21-2001 10:48 AM
Re: Edit log flie that is in use?
No soap:
The selected file "/var/adm/syslog/mail.log" is too big to view as it has "1096043546" bytes. Use another trim action to reduce the size to "32768" bytes or less, then try the trim to a line number action again.
This file busts 32k within a day of being zeroed-out.
Other ideas?
Jim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-21-2001 10:55 AM
тАО06-21-2001 10:55 AM
Re: Edit log flie that is in use?
Do you have room to make a copy of the file somewhere? Maybe to tape?
Then you could just do a '> mail.log' to zero it out again.
I think what I would then do is set up a nightly cron job to make a copy of the mail.log to mail.log.date and then compress it and then zero out the mail.log again. Then periodically if you don't need to keep them, delete the old logs.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-21-2001 10:58 AM
тАО06-21-2001 10:58 AM
Re: Edit log flie that is in use?
Try this:
1. First get the line number at which the region in the log you want to retain, starts:
# grep -n
2. Using this line number (call it 'LINE') as the trim point, do:
# cd /var/adm/syslog
# sed -n $LINE,'$p' syslog.log > syslog.trimmed
# mv sylog.trimmed syslog.log
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-21-2001 11:00 AM
тАО06-21-2001 11:00 AM
Re: Edit log flie that is in use?
...oh, make that "mail.log" not "syslog.log"...
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-21-2001 11:11 AM
тАО06-21-2001 11:11 AM
Re: Edit log flie that is in use?
It trims with no problem.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-21-2001 12:22 PM
тАО06-21-2001 12:22 PM
Re: Edit log flie that is in use?
# cd /var/adm/syslog
# mv mail.log mail.log.old
# > mail.log
# kill -HUP $(cat /var/run/syslog.pid)
# mv mail.log mail.log.new
# grep '^Jun' mail.log.old > mail.log
# cat mail.log.new >> mail.log && kill -HUP $(cat /var/run/syslog.pid)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-21-2001 01:29 PM
тАО06-21-2001 01:29 PM
Re: Edit log flie that is in use?
Patrick, yeah, 1GB. Our InfoSec folks have an insane level of logging turned on in sendmail. The file size you saw was from April 27 until now.
James, I think I could script what you are suggesting and possibly get away with it. The switcheroo would have to be lightning fast, though. I'm a little unsure how unhappy syslogd would be over that. When I did the mv, would the inode change for the mail.log file that syslogd is writing to?
John, I already tried SAM in the manner you describe. See my 18:48 GMT reply to Patrick.
Jordan, I had to think about yours for a bit. Let me make sure I understand what you propose:
a. rename mail.log to mail.log.old (syslogd now writing sendmail logging to mail.log.old?)
b. create a new, zero-sized mail.log
c. SIGHUP syslogd (flip syslogd's writing of sendmail logging back to mail.log?)
d. rename mail.log to mail.log.new (syslogd now writing to mail.log.new?)
e. pull all of the june messages out of mail.log.old and put them in a new mail.log file.
f. append mail.log.new to the end of mail.log and SIGHUP syslogd (flip syslogd's writing of sendmail logging back to mail.log?)
Let me know (post here again) if I understand everything correctly. It sounds like it will do exactly what I need.
Folks, what makes this a bit complicated is that log messages are being written to the end of mail.log at a rate of one to five messages PER SECOND. That doesn't allow me any time to dawdle around diddling with files. However, what Jordan proposes looks like it can be done with everything hot because SIGHUP'ing syslogd can be made coincident with filename changes.
Thanks again everybody. Once I get a confirmation from Jordan, I'm going to try his procedure. I will post a final follow-up indicating success or failure.
Cheers,
Jim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-21-2001 02:04 PM
тАО06-21-2001 02:04 PM
SolutionYou can rename the files while their open. SIGHUP tells Syslogd to flush and close all open file descriptors, re-read its configuration file, and open all log files by name.
For the last step, I'm assuming that cat will read the growing log file to true eof and SIGHUP will be issued without delay. Since syslog will be flushing its buffers before closing the file, a few entries may be missed in the transfer.