How to tail multiple files at once in Linux

If you are a Linux system administrator, monitoring log files on a server host will be one of your daily routines. The tail command comes in handy as you can monitor a log file in real-time as it grows, by running tail with "-f" option.

What if you want to monitor more than one log file at the same time? You could run tail on multiple terminals, or launch multiple instances of tail in one terminal by using terminal multiplexers such as screen. But neither approach is convenient in monitoring mupltiple log files at once.

In this post, I will describe how to tail multiple files at once in Linux, by using a command-line tool called multitail.

multitail creates ncurses-based multiple screens inside a terminal, each of which can run a separate instance of tail-like file viewer.

To install multitail on Ubuntu or Debian:

$ sudo apt-get install multitail

To install multitail on Fedora:

$ sudo yum install multitail

To install multitail on CentOS or RHEL, first set up Repoforge on your system, and then run:

$ sudo yum install multitail

Monitor multiple log files as they grow in horizontally split screens

$ sudo multitail --follow-all /var/log/auth.log /var/log/kern.log /var/log/syslog

Monitor multiple log files as they grow in vertically split screens

$ sudo multitail -s 3 --follow-all /var/log/auth.log /var/log/kern.log /var/log/syslog

Monitor multiple command outputs simultaneously

Besides tailing log files, multitail can also monitor the output of an external command, as the execution of the command is in progress. For example, you can run multiple ping commands, and monitor individual ping outputs simultaneously in split screens as follows.

$ multitail -l "ping twitter.com" -l "ping google.com"

Subscribe to Xmodulo

Do you want to receive Linux FAQs, detailed tutorials and tips published at Xmodulo? Enter your email address below, and we will deliver our Linux posts straight to your email box, for free. Delivery powered by Google Feedburner.

The following two tabs change content below.
Dan Nanni is the founder and also a regular contributor of Xmodulo.com. He is a Linux/FOSS enthusiast who loves to get his hands dirty with his Linux box. He likes to procrastinate when he is supposed to be busy and productive. When he is otherwise free, he likes to watch movies and shop for the coolest gadgets.
Your name can also be listed here. Write for us as a freelancer.

6 thoughts on “How to tail multiple files at once in Linux

  1. I am surprised the article didn't even mention the fact that tail can already be used on multiple files. There may be good reasons for wanting something else -- multitail's ncurses-based windows sounds useful -- but that doesn't mean plain old tail is necessarily useless. I find it quite OK if the files aren't being updated frequently.

  2. What is wrong with "tail -f file1 file2..." I do this all the time eg to see any log output on a system I might do "tail -f /var/log/*.log"

  3. This is what I was looking for. very cool that I came across this article. in the end I will not have to fire off a few windows for a single terminal tail command. Now I have everything in the window radiator manufacturer. Great stuff, thanks

  4. Never quite understood what multitail gives you above and beyond a decent "screen" set up with whatever customization you want under ~/.screenrc/ to be honest? I use this setup for operating across multiple load balancers simultaneously as well since whilst the commands to the primary and secondary LBs are very similar there are sometimes minor differences and you certainly wouldn't want to run them at the exact same time so things like clusterssh wouldn't achieve the right outcome either.

    • I like the flexibility of multitail, e.g., show 5 logfiles while merging 2 (with optional filtering) and put them in 2 columns with only one in the left column, etc.

      Like anything else, it all comes down to your need. If screen is sufficient for you, then that's great. If not, consider something like multitail.

Leave a comment

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

Current ye@r *