in reply to Re: Re: Is this the most efficient way to monitor log files..
in thread Is this the most efficient way to monitor log files..

Read the last paragraph before the code again. You can just wrap the part I have bracketed as "main" with

while (1) {

at the top and

  sleep $nsec;}

at the bottom. (Put your own condition in there if you like, or use a "last" statement inside the loop wherever it's easy to decide that the process can stop.

Also, do heed grinder's advice (which followed my reply). He's right about how to read the log files.