1. Command function
tailf tracks log file growth, the same as tail -f. tailf will output the last 10 lines of the file and then wait for the file to grow.
2. Grammar format
tailf option file
Parameter Description
parameter |
Parameter Description |
-n |
Specify the number of lines at the end of the display file (the last 10 lines are displayed by default) |
3. Example of use
Example 1 tailf trace log
[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 "[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
Example 2 Display the last 4 lines
[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