Jeff Pang wrote:
hi,lists,

Hello,

I have a log file which is a symbol link to the real logfile,shown as following:

$ll mssvr.log
lrwxrwxrwx    1 cmail root           40 Jan 14 00:00 mssvr.log -> 
/home/cmail/logs/mssvr.log.2006-01-14

I have to access this file in perl script with unix 'tail -f' command.Part of 
the code is below:

    open (TAIL,"tail -f $log|") or die "can't open pipe:$!";
    while(<TAIL>)
    {
        do something...
    }

This script is a daemon script which run permanently.There is no problem when 
in the same day.But when the date changed,the symbol link file will point to 
another real logfile automatically (which decided by other application 
program),such as:

lrwxrwxrwx    1 cmail root           40 Jan 14 00:00 mssvr.log -> 
/home/cmail/logs/mssvr.log.2006-01-15

As you see,it's '2006-01-15' now, not '2006-01-14' as before.So the 'tail -f 
$log' become no use for the new symbol link file,and I can't get any input from 
the new logfile in the script.

How can I adjust this problem?Thanks a lot.

Have you looked at File::Tail::App? It will simplify your life a lot, if File::Tail catches that its tailing a link and its targte changes. II *think* it should be transparent.

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to