Operations 2 min read

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.

Qunar Tech Salon
Qunar Tech Salon
Qunar Tech Salon
How to Follow Log Files and Handle Log Rotation with tail

How to follow log files

tail -f /path/to/log/file | grep -i error

This command is commonly used to watch a log for suspicious entries such as error output.

What to do when log rotation occurs

tail -F

The 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.

operationsLinuxSystem AdministrationLog Monitoringlog rotationtail
Qunar Tech Salon
Written by

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.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.