Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I need to tail -f a log file that is rotated.

This is the exact same issue as the one here, but on OS X:

Why does less tail mode stop working?

So how can I constantly track a file whose inode might change under OS X?

share|improve this question
    
Not seeing any parameter called --follow-name on Ubuntu for tail. I do see --follow, which is the long form for -f. –  Nicholi Jul 28 '11 at 23:32

1 Answer 1

up vote 1 down vote accepted

From Ubuntu Lucid (coreutils 7.4)

   -f, --follow[={name|descriptor}]
          output appended data as the file grows; -f, --follow, and --follow=descriptor are equivalent

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

From Mac OS X 10.6 (10A432)

 -f      The -f option causes tail to not stop when end of file is
         reached, but rather to wait for additional data to be appended to
         the input.  The -f option is ignored if the standard input is a
         pipe, but not if it is a FIFO.

 -F      The -F option implies the -f option, but tail will also check to
         see if the file being followed has been renamed or rotated.  The
         file is closed and reopened when tail detects that the filename
         being read from has a new inode number.  The -F option is ignored
         if reading from standard input rather than a file.

Assuming you want the --follow=/tmp/something.txt behavior on Linux, that would mean on Mac what you want is:

tail -F /tmp/somefile.txt

Edit: Just tested on Mac OSX (Snow Leopard) and -F will only open the filename you input, and NOT follow the inode/file descriptor of the file it opened with when it is moved.

share|improve this answer
    
reformulated my question to match your answer. Seems to work fine so far, thanks a lot : ) –  Weezy Jul 28 '11 at 23:46
    
Excellent, in case you get caught up in stuff like this again just remember the all useful 'man' command. Can usually get you out of a bind, or at least provide you with enormous amounts of text to read :). –  Nicholi Jul 28 '11 at 23:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.