近頃のディストリビューションで採用されているバージョンの tail コマンドは inotify を使っているため、環境によっては tail -f が希望通りに機能しないことがあるようです。 Ubuntu 12.04 の LiveCD から tail -f を試してみたのですが、動きませんでした。
| # tail -f /var/log/tomoyo/reject_000.txt /var/log/tomoyo/reject_001.txt /var/log/tomoyo/reject_002.txt /var/log/tomoyo/reject_003.txt |
strace で確認すると、特定のファイルディスクリプタの読み込みでブロックしていることが判ります。
|
# strace -p `pidof tail` Process 4418 attached - interrupt to quit read(7,^C <unfinished ...> Process 4418 detached |
ls で確認すると、そのファイルとは anon_inode:inotify であることが判ります。
|
# ls -l /proc/`pidof tail`/fd/ total 0 lrwx------ 1 root root 64 May 2 11:40 0 -> /dev/pts/0 lrwx------ 1 root root 64 May 2 11:40 1 -> /dev/pts/0 lrwx------ 1 root root 64 May 2 11:40 2 -> /dev/pts/0 lr-x------ 1 root root 64 May 2 11:40 3 -> /var/log/tomoyo/reject_000.log lr-x------ 1 root root 64 May 2 11:40 4 -> /var/log/tomoyo/reject_001.log lr-x------ 1 root root 64 May 2 11:40 5 -> /var/log/tomoyo/reject_002.log lr-x------ 1 root root 64 May 2 11:41 6 -> /var/log/tomoyo/reject_003.log lr-x------ 1 root root 64 May 2 11:41 7 -> anon_inode:inotify |
inotify を使わせないようにするには、 ---disable-inotify という隠しオプションを使います。 - が3つ連続していることに注意してください。
| # tail ---disable-inotify -f /var/log/tomoyo/reject_000.txt /var/log/tomoyo/reject_001.txt /var/log/tomoyo/reject_002.txt /var/log/tomoyo/reject_003.txt |
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=583198