[Sussex] Ruby file open question

Thomas Adam thomas at edulinux.homeunix.org
Tue Nov 1 14:39:49 UTC 2005


On Tue, Nov 01, 2005 at 09:12:39AM +0000, Ronan Chilvers wrote:
> I want the script to respond to changes in a logfile fairly quickly.
> Currently it takes about 2 or 3 seconds for a change in the logfile
> to be picked up by the script... I'll play around with the interval -
> thanks for pointing that out.

You're welcome.  Here's something I tried in irb:

require 'file/tail'
File::Tail::Logfile.open("/home/n6tadam/.xsession-errors", 
                          :interval => 0.1) 
{ |log| log.tail() {|data| puts data} }

... seems to work OK in terms of rapid reponse.
                
-- Thomas Adam

--  
"Try not to want people to like you too much, you'll just need more and
more flatteries to recharge your batteries." -- Jeffrey Lewis.




More information about the Sussex mailing list