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. |
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 |
All times are GMT -5. The time now is 07:08 PM. |