in reply to 'better mousetrap': how to perform timed event
I would figure, if the size of your log file changes, then you can easily seek to the point in your file that has changed (you do have the old file size), read the data from it (which should be fast if the new data is small), and decide if your event has indeed occured. If it's not your event, just fall out and go back to your polling. If it is, do your magic.while (1) { $new_size = -s $file; if ($new_size > $old_size) { # $old_size is defined before this lo +op if ( event_occured() ) { sleep($map_vTime); do_your_thing(); $old_size = $new_size; } $old_size = $new_size; } sleep($normal_sleep_interval); }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: 'better mousetrap': how to perform timed event
by snafu (Chaplain) on Apr 25, 2003 at 23:44 UTC |