I don't know why it can't work for me. I have tested it as following: $ln -s mssvr.log.2006-01-14 mylog $tail --follow=name --retry mylog
Now this command output the content of mssvr.log.2006-01-14 correctly. So I continue to excute these commands (open another terminal): $rm -f mylog $ln -s mssvr.err mylog mssvr.err is a real file not symlink. So I expect the before command of 'tail --follow=name --retry mylog' should change to output the content of mssvr.err.But when I return to the first terminal,I found the output of 'tail' is still the content of mssvr.log.2006-01-14,not mssvr.err's. So strange it is for me. -----Original Message----- >From: John Doe <[EMAIL PROTECTED]> >Sent: Jan 14, 2006 8:34 AM >To: beginners@perl.org >Subject: Re: the 'tail' problem > >Jeff Pang am Samstag, 14. Januar 2006 12.52: >> Thanks for Adriano.I have tried the way that mentioned by you,and found >> it's no use for me. should the '-F' option have no effect for symlinks >> maybe? >> >> -----Original Message----- >> >> >From: Adriano Ferreira <[EMAIL PROTECTED]> >> >Sent: Jan 14, 2006 7:23 PM >> >To: Jeff Pang <[EMAIL PROTECTED]>, beginners@perl.org >> >Subject: Re: the 'tail' problem >> > >> >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. > >Hi > >After reading man tail I tested > > tail --retry --follow=name testlog > >where testlog is a symlink. While this command is running, I can do (from >another console): > > rm testlog > ln -s testlog1 testlog > rm testlog > ln -s testlog2 testlog > >It does what you want. > >Maybe File::Tail will also do what you want, just test it (and read the man) > >hth >joe > >-- >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] ><http://learn.perl.org/> <http://learn.perl.org/first-response> > > -- http://home.earthlink.net/~pangj/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>