in reply to How do I tail -f a file if it is NFS mounted?
#!/usr/bin/perl -w use IO::File; use strict; my $tail = new IO::File; $tail->open("<./log.dat"); while(1){ my @lines=$tail->getlines(); if(0==scalar(@lines)){ # wait 1 second before trying again... # to keep from hogging CPU cycles sleep 1; }else{ my $line; foreach $line(@lines){ chomp $line; print " \"$line\"\n"; } } }
|
|---|