What is the use of Linux's tailf command
This article mainly introduces the relevant knowledge of the use of Linux's tailf command, the content is detailed and easy to understand, the operation is simple and fast, and has a certain reference value. I believe you will gain something after reading this Linux tailf command. Let's take a look at it.
The common Linux command tailf command is almost equivalent to tail-f, which should be more similar to tail-- follow=name strictly speaking. It can also continue to trace when the file is renamed, which is especially suitable for log file tracking (follow the growth of a log file).
Tailf displays several lines at the end of the specified file on the screen, which is usually used for the trace output of log files
Note that unlike tail-f, if the file does not grow, it will not access the disk file. Tailf is especially suitable for tracking log files on laptops because it saves power and reduces disk access. The tailf command is not a script, but a binary execution file compiled in C code, which is not available after some Linux installations.
The difference between tailf and tail-f
Tailf always reads from the beginning of the file, while tail-f starts at the end of the file.
When tailf check files grow, use the file name, using the stat system call; and tail-f uses the open file descriptor; Note: tail can also achieve a similar effect of tracking file names; but tail always uses fstat system calls instead of stat system calls; the result is: by default, when tail files are secretly deleted, tail does not know, and tailf knows.
The syntax tailf logfile # dynamically tracks the log file logfile, initially printing the last 10 lines of the file. The option-n,-- lines NUMBER # outputs the last few lines-NUMBER # is the same as NUMBER `- n NUMBER'-V,-- version # outputs version information and exits-h,-- help # displays help and exits the parameter target: specify the target log.
Example tailf log/WEB.LOG tailf-n 5 log2014.log # shows the last five lines of the file. This is the end of the article on "what is the use of Linux's tailf command?" Thank you for reading! I believe you all have a certain understanding of the knowledge of "what is the use of Linux's tailf command". If you want to learn more, you are welcome to follow the industry information channel.