Jeff,

Maybe all you have to do is make some adjustments to the pipe you're
opening. Besides the well known "-f" switch, some tail's (like gnu
tail) support "-F" which means a file is followed by its name and the
opening is retried from time to time. From "man tail" (GNU):

       -F     same as --follow=name --retry

      With  --follow  (-f),  tail  defaults to following the file descriptor,
      which means that even if a tail'ed file is renamed, tail will  continue
      to  track  its  end.   This  default behavior is not desirable when you
      really want to track the actual name of the file, not the file descrip-
      tor (e.g., log rotation).  Use --follow=name in that case.  That causes
      tail to track the named file by reopening it periodically to see if  it
      has been removed and recreated by some other program.

If you found it works for symlinks, all you have to do is use

>     open (TAIL,"tail -F $log|") or die "can't open pipe:$!";

Regards,
Adriano Ferreira.

On 1/14/06, Jeff Pang <[EMAIL PROTECTED]> wrote:
> I have a log file which is a symbol link to the real logfile,shown as 
> following:

> 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:$!";

> 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:
>
[snip]
>
> How can I adjust this problem?Thanks a lot.

--
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