use strict; use warnings; use POSIX; use IO::Handle; my $appLog = '/tmp/t.txt'; my $error = 'Fatal Error'; exit if (my $pid = fork); defined($pid) or die "Can't fork: $!"; POSIX:setsid() or die "Can't setsid: $!"; $SIG{TERM} = sub { close LOG; exit; }; $SIG{INT} = $SIG{TERM}; $SIG{PIPE} = 'IGNORE'; $SIG{HUP} = \&readLog; sub readLog { open(LOG,"<$appLog") or die("Unable to open $appLog: $!"); while () { ;; } # read to the end of the log LOG->clearerr(); # and clear EOF flag } &readLog; for (;;) { while () { #&pageMe if /$error/; print; } sleep 2; LOG->clearerr(); # clear EOF flag } #### use strict; use warnings; use POSIX; my $appLog = '/tmp/t.txt'; my $error = 'Fatal Error'; exit if (my $pid = fork); defined($pid) or die "Can't fork: $!"; POSIX:setsid() or die "Can't setsid: $!"; my $tail = open(LOG,"/usr/local/bin/tail -F $appLog|") or die "Can't tail: $!"; $SIG{INT} = sub { close LOG; kill 3, $tail; exit; }; $SIG{TERM} = $SIG{INT}; $SIG{PIPE} = 'IGNORE'; $SIG{HUP} = 'IGNORE'; while () { #&pageMe if /$error/; print; }