Reading logs? keep reading a file?

Hi I am trying to read from /var/log/messages
but the script will finish..
ok ok.. what I am trying to do is open the log or logs and wait for a
phrase of my choosing to appear then do something..
I know the regex part and how to use it.. I know how to open files to read.. I just don't know how to read a file and tell ruby to keep reading it for new entries on it..


Im guessing you going to have to sleep and poll the modification
timestamp on the file at regular intervals to see if its changed. If it
has, and you have the file open, you can read bytes until you get EOF,
print them out and go back to sleep again.

It might be useful to read the C source code to things like tail.

Eno wrote: