in reply to Re: Automatically killing a child
in thread Automatically killing a child

Hi everyone,

This was a real interesting topic, and ++ to all for your great contributions. In the end, I removed tail from the code, and just hard coded a simple perl based tail into my code. That works, plus I don't have to fork another process.

#!/usr/bin/perl # Known issue # If the file gets truncated, the script will not terminate # ==================================================================== +========= use IO::Handle; autoflush STDOUT; use Fcntl qw(:seek); $file = 'mylog.txt'; $started = 0; #set to 1 if you want the file to start reading from +the start of the logfile while(1) { open LOG, $file or die "$file could not be opened."; seek LOG, $pos, SEEK_SET if defined $pos; while(<LOG>) { chomp; if($started) { print "$_\n"; } } $pos = tell LOG; close LOG; sleep 1; $started = 1; } exit(0);

Thanks!

     |\/| _. _ _  ._
www. |  |(_|_>_>\/| | .net
                /
The more I learn the more I realise I don't know.
- Albert Einstein