Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Software
User Name
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.


  Search this Thread
Old 07-17-2002, 04:15 PM   #1
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!
Old 07-19-2002, 03:54 AM   #2
Senior Member
Registered: Dec 2001
Location: The Netherlands
Distribution: Ubuntu
Posts: 1,316

Rep: Reputation: 47
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.

tail -f logfile >> tempoutput&

while [ 1 ]
   grep ERROR tempoutput

   cat /dev/null > tempoutput
   sleep 1


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 07:36 AM
Monitor Frequency problem when starting with SuSE Live CD limboonlee SUSE / openSUSE 3 05-11-2005 11:48 AM
Log into netwrok @ work with live CD? Eradicator Linux - Networking 3 07-29-2004 09:47 PM
How do i log-in on Suse Live-eval 8.2? terdmonkey18 Linux - General 3 10-04-2003 02:45 PM
download monitor/log radnix Linux - Security 4 06-11-2003 09:13 PM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:14 AM.

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