Skip to content
Home » Linux » How to Monitor Specific Terms by Filtering Output of "tail -f" on Linux

How to Monitor Specific Terms by Filtering Output of "tail -f" on Linux

You might feel tedious or nothing special when watching log files by tail -f, especially when the log files contain thousands of transaction at the same time on your server.

In real world, most of the records in the log files are normal ones, we should try to monitor something we are interested in. If possible, we want one command that can filter noise out of the output of tail -f.

For example, I want to know who are scanning web page: /wp/wp-admin which normal users are not interested on my web server, I can do this
[root@localhost ~]# tail -f /var/log/httpd/www.example.com-access_log | grep --line-buffered "/wp/wp-admin"
The key option of grep is --line-buffered which is to output buffer in real-time.

Leave a Reply

Your email address will not be published. Required fields are marked *