|

楼主 |
发表于 2008-1-11 17:42:15
|
显示全部楼层
Post by kingway;1805733
这两个操作中的 test.log 是不同的两个文件,主要是文件的 i-node 不同(不知这样说对不对)。tail 中获得的 i-node 其实就是 mv 后的 test.log.1 的 i-node。所以,应该这样:
$ echo "abcd" >> test.log.1
这是 tail 就会将 abcd 打印出来。
多谢,inode 就是 file descriptor 吧?
刚才在网上找到了这个,这个参数可以解决:
-F 参数可以解决
tail --help
-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 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. |
|