LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 07-17-2002, 03:15 PM   #1
ifm
Member
 
Registered: Jun 2002
Location: USA
Distribution: RH7.3 & YDL2.1
Posts: 124

Rep: Reputation: 15
Question A live log monitor script ?


Got a question/request.

I want to make a simple script that watches a log "in real time" and then does something when something is seen happen in a log file.

I am capable of doing all the glory of the action, however I cannot find a good way (any way actually) to make a script run and monitor a log file in real time while the file is being written too by another program. OR make the script watch to see if the log file is written too, then reads the end of the log and sees if something happened that it should do something with.

Any ideas? Am I dreaming in thinking this can happen?

Any pointers to an example script, code snip, or idea... let me know!
Thanks.
 
Old 07-19-2002, 02:54 AM   #2
Mik
Senior Member
 
Registered: Dec 2001
Location: The Netherlands
Distribution: Ubuntu
Posts: 1,316

Rep: Reputation: 46
There might be more elegant ways but maybe something like this could be an idea.

First run something like 'tail -f logfile >> tempoutput&'
That will append anything that gets added to the logfile to a tempfile. All you have to do in your script is a loop which periodically checks the tempfile and then clears the contents.

Code:
#!/bin/bash
tail -f logfile >> tempoutput&

while [ 1 ]
do
   grep ERROR tempoutput

   cat /dev/null > tempoutput
   sleep 1
done
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Using the log to monitor the programs used blufire Programming 7 06-18-2005 06:36 AM
Monitor Frequency problem when starting with SuSE Live CD limboonlee Suse/Novell 3 05-11-2005 10:48 AM
Log into netwrok @ work with live CD? Eradicator Linux - Networking 3 07-29-2004 08:47 PM
How do i log-in on Suse Live-eval 8.2? terdmonkey18 Linux - General 3 10-04-2003 01:45 PM
download monitor/log radnix Linux - Security 4 06-11-2003 08:13 PM


All times are GMT -5. The time now is 10:31 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration