tailf 跟踪日志文件

1.命令功能

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

2.语法格式

tailf  option  file

参数说明

参数

参数说明

-n

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

3.使用范例

范例1 tailf 跟踪日志

[root@localhost 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 "fs-multiple-roots-supported@vandyke.com"

Apr 24 04:21:04 localhost sftp-server[1444]: error: Unknown extended request "openex@vandyke.com"

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行

[root@localhost 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
posted @ 2018-04-25 21:43  joe.chu  阅读(2013)  评论(0编辑  收藏  举报