tuxtoti has asked for the wisdom of the Perl Monks concerning the following question:
Let me explain my intention. I have a constantly changing log and the log is rotated every hour(so a new log file is created every hour). What i intend to do is have a configuration file which has the current hour's log's filename and every hour I'll change the filename in this config file (externally from a diff prog ) and pass a INTsignal to the above code for it to pick up the newfile name.use File::Tail; $SIG{'INT'} = 'INT_handler'; sub INT_handler { open(FILE,"/tmp/filename") || die "Cannot open file:$!"; $cur_filename=<FILE>; close(FILE); print("Don't Interrupt!\n"); chomp($cur_filename); $file=File::Tail->new(name=>$cur_filename, maxinterval=>3, adjusta +fter=>2,tail=>-1); } $cur_filename=$ARGV[0]; $file=File::Tail->new(name=>$cur_filename, maxinterval=>3, adjustafter +=>2,tail=>-1); while (defined($line=$file->read)) { print $line; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: File::Tail issue..
by ikegami (Patriarch) on Mar 20, 2009 at 14:59 UTC | |
by tuxtoti (Initiate) on Mar 20, 2009 at 17:54 UTC | |
by ikegami (Patriarch) on Mar 20, 2009 at 18:03 UTC | |
by Anonymous Monk on Mar 20, 2009 at 21:08 UTC | |
by ikegami (Patriarch) on Mar 20, 2009 at 21:32 UTC | |
|
Interrupting File::Tail with a signal handler
by ig (Vicar) on Mar 20, 2009 at 20:07 UTC | |
|
Re: File::Tail issue..
by targetsmart (Curate) on Mar 20, 2009 at 16:06 UTC | |
|
Re: File::Tail issue..
by VinsWorldcom (Prior) on Mar 20, 2009 at 15:01 UTC | |
by kennethk (Abbot) on Mar 20, 2009 at 15:05 UTC |