I think it needs to be said again: tail -f sounds like the ticket. You can combine the tail -f and the grep in a simple Perl script. Whatever the implementation, the idea is to keep the file open, and attempt to read another line, say, once per second, or once every five seconds. If the read fails, it means no data has been appended to the file. If it succeeds, there is new data; read and examine, and if it's a hit, take some action (terminate? send another process a signal? send an email?)