tailf 跟踪日志文件

Posted joe.chu

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了tailf 跟踪日志文件相关的知识,希望对你有一定的参考价值。

1.命令功能

tailf 跟踪日志文件增长,作用跟tail –f相同。tailf将输出文件的最后10行,然后等待文件增长。

2.语法格式

tailf  option  file

参数说明

参数

参数说明

-n

指定显示文件最后的行数(默认显示最后10行)

3.使用范例

范例1 tailf 跟踪日志

[[email protected] chu]# tailf /var/log/messages

Apr 24 04:04:44 localhost sshd[1410]: error: Bind to port 22 on 0.0.0.0 failed: Address already in use.

Apr 24 04:04:44 localhost sshd[1410]: error: Bind to port 22 on :: failed: Address already in use.

Apr 24 04:04:44 localhost sshd[1410]: fatal: Cannot bind any address.

Apr 24 04:20:55 localhost sshd[1429]: Accepted password for root from 172.16.2.100 port 3895 ssh2

Apr 24 04:21:04 localhost sftp-server[1444]: error: Unknown extended request "[email protected]"

Apr 24 04:21:04 localhost sftp-server[1444]: error: Unknown extended request "[email protected]"

Apr 24 04:21:04 localhost sftp-server[1444]: error: Unknown extended request "vendor-id"

Apr 24 04:22:44 localhost sshd[1467]: Accepted password for root from 172.16.2.100 port 4045 ssh2

Apr 24 04:22:47 localhost sshd[1482]: Accepted password for root from 172.16.2.100 port 4048 ssh2

Apr 24 04:23:03 localhost sshd[1498]: Accepted password for root from 172.16.2.100 port 4063 ssh2

范例2 显示最后4行

[[email protected] chu]# tailf -4 /var/log/messages

Apr 24 04:21:04 localhost sftp-server[1444]: error: Unknown extended request "vendor-id"

Apr 24 04:22:44 localhost sshd[1467]: Accepted password for root from 172.16.2.100 port 4045 ssh2

Apr 24 04:22:47 localhost sshd[1482]: Accepted password for root from 172.16.2.100 port 4048 ssh2

Apr 24 04:23:03 localhost sshd[1498]: Accepted password for root from 172.16.2.100 port 4063 ssh2

以上是关于tailf 跟踪日志文件的主要内容,如果未能解决你的问题,请参考以下文章

Linux系统 multitail 同时跟踪查看多个日志文件

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

tailf,tail -f,tail -F区别

Linux 实时查看日志文件动态内容

linux服务器查看项目日志命令

tail命令