tailf、tail -f、tail -F三者区别

tail -f、tail -F、taif 三者区别

tail 命令的作用是输出文件尾部,默认是打印文件最后10行到标准输出。若指定多个文件,则会依次处理各给定文件,并以文件名作为头部信息。形如:

tail file1 file2
==> file1 <==
line1
...
line10

==> file2 <==
line1
...
line10

tail -f

命令手册描述如下:

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

即,tail -f 会根据文件描述符进行追踪,使用 -f, –follow–follow=descriptor 是等价的。实际测试,当文件改名或被删除时,追踪会停止。

tail -F

命令手册描述如下:

same as --follow=name --retry

即,tail -F 会根据文件名进行追踪并保持重试,当文件文件被移动或删除后,若再次创建同名文件,则会继续追踪该同名文件。

tailf

命令手册描述如下:

tailf will print out the last 10 lines of a file and then wait for the file to grow. It is similar to tail -f but does not access the file when it is not growing. This has the side effect of not updating the access time for the file, so a filesystem flush does not occur periodically when no log activity is happening.
tailf is extremely useful for monitoring log files on a laptop when logging is infrequent and the user desires that the hard disk spin down to conserve battery life.

即,使用 tailf 时,如果文件不增长则不会访问磁盘文件,当然也就不会更新文件的访问时间。该特性对于在笔记本上监控日志文件很有用,当日志打印不那么频繁时,我们希望降低硬盘转速以省电。

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值