How to Follow Log Files and Handle Log Rotation with tail
This article explains how to use the Linux tail command to monitor log files in real time, filter errors, and reliably continue following logs after rotation by using the -F option, providing practical guidance for system administrators and developers.
How to follow log files
tail -f /path/to/log/file | grep -i errorThis command is commonly used to watch a log for suspicious entries such as error output.
What to do when log rotation occurs
tail -FThe manual page for tail explains that -F is equivalent to --follow=name --retry , which makes tail follow the file name even after rotation, useful for files like Tomcat's catalina.out .
Author: He Weiping, Qunar Travel Division, search technology and database researcher, translator of the first Chinese PostgreSQL manual and the third edition of Programming Perl, with nearly 18 years of IT experience.
The article is originally from the company wiki “老何的1001夜”. Qunar colleagues can log in to the wiki for more articles.
Qunar Tech Salon
Qunar Tech Salon is a learning and exchange platform for Qunar engineers and industry peers. We share cutting-edge technology trends and topics, providing a free platform for mid-to-senior technical professionals to exchange and learn.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.