LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 03-21-2007, 08:34 PM   #1
apollyonus
LQ Newbie
 
Registered: Oct 2003
Location: Elgin
Distribution: Slackware
Posts: 5

Rep: Reputation: 0
sed with large text files?


Plain & simple:

/var/log/messages shows useless WARNING messages on some of our servers.

Monitoring server Sends email with notifications of said useless WARNINGs.

This causes much Grrr in the noc, as we've been going in and editing the file with vi, hoping to change WARNING to warning and save the file before anything else writes to it.

I've tried executing the following command

sed s/WARNING/warning/g /var/log/messages > /var/log/messages.tmp && mv /var/log/messages.tmp /var/log/messages

It worked as expected, but didn't complain

Some one else tried writing a perl script which basically did the same thing, but would sporadically truncate the file (even worse)

Is there a way that I can tell if syslogng is writing to the file while sed & mv are getting rid of the uglies?
 
Old 03-21-2007, 09:42 PM   #2
dgar
Member
 
Registered: Jun 2005
Location: Candia, NH
Distribution: Ubuntu, FC, RHE3, RHE4, CentOS
Posts: 121

Rep: Reputation: 15
Too tired to give a detailed explanation but two things come to mind:
1) Configure /etc/syslog.conf to not put the WARNING level messages in /var/log/messages
or
2) syslogd can be sent a signal with the kill command to facilitate mucking with the log file while syslogd may write to it.

Trying to edit the file by overwriting it is poor form.
 
Old 03-21-2007, 11:14 PM   #3
apollyonus
LQ Newbie
 
Registered: Oct 2003
Location: Elgin
Distribution: Slackware
Posts: 5

Original Poster
Rep: Reputation: 0
uh... thanks for your quick response. Obviously the first suggestion is out of the question, and second one is somewhat closer. This project is for nought without an automated process.

Still searching
 
Old 03-22-2007, 07:33 AM   #4
dgar
Member
 
Registered: Jun 2005
Location: Candia, NH
Distribution: Ubuntu, FC, RHE3, RHE4, CentOS
Posts: 121

Rep: Reputation: 15
Don't discount syslogd.conf out of hand unless you really understand what it is capable of.

You aren't the first administrator to aim scripts at the log files. syslogd is heavily designed for just such manipulations. Both in the conf file and in the acrobatics the running daemon is capable of via signals.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Sorting large text files tmaxx AIX 14 02-19-2009 06:32 PM
extracting a chunk of text from a large text file lothario Linux - Software 3 02-28-2007 08:16 AM
using sed to parse large directory mastro Programming 2 04-13-2006 10:58 AM
SED - display text on specific line of text file 3saul Linux - Software 3 12-29-2005 04:32 PM
Script file to replace large text blocks in files? stodge Linux - Software 0 09-27-2003 10:53 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 08:43 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration