する必要があるテール-fローテーションされるログ ファイル。
これはちょうどここでの問題と同じ問題ですが、OS X 上で発生します。
では、OS X で inode が変更される可能性があるファイルを継続的に追跡するにはどうすればよいでしょうか?
答え1
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
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.
--follow= が必要な場合/tmp/何か.txtLinux での動作は、Mac で必要な動作と同じになります。
tail -F /tmp/somefile.txt
編集: Mac OSX (Snow Leopard)でテストしたところ、-F入力したファイル名のみが開かれ、移動時に開かれたファイルの inode/ファイル記述子には従いません。