Logs – How to Monitor Only the Last N Lines of a Log File

logsmonitoringtail

I have a growing log file for which I want to display only the last 15 lines. Here is what I know I can do:

tail -n 15 -F mylogfile.txt

As the log file is filled, tail appends the last lines to the display.

I am looking for a solution that only displays the last 15 lines and get rid of the lines before the last 15 after it has been updated. Would you have an idea?

Best Answer

It might suffice to use watch:

$ watch tail -n 15 mylogfile.txt
Related Question