Posted by chantra on April 29th, 2013
Many times you will end up tailing multiple files simultaneously. There is a sweet linux utility called multitail that will let you tail multiple files at the same time within the same shell.
And not only will you be able to tail multiple files! You will also be able to run multiple commands and tail their outputs!
multitail allows you to tail multiple files within the same window. Outputs can be either merged together or shown in split panes either horizontally or vertically.
On Debian, installation is pretty straightforward and only needs a bit of apt-geting:
# apt-get install multitail
There is a tons of ways to use that command. The man page is filled with different switches that can be use to better customize the output.
I am going to show you a few ways to use it.
First, let's aggregate the output of 2 log files within the same window. This is done by using a command like:
# multitail -i /var/log/daemon.log -I /var/log/auth.log
This tells multitail to tail files /var/log/daemon.log and /var/log/auth.log and to merge the output of /var/log/auth.log into the first window.
You can also have the same files' output in 2 different panes:
# multitail -i /var/log/daemon.log -i /var/log/syslog
This will have the 2 files displayed in 2 different panes split across the horizontal axis.
# multitail -s 2 -i /var/log/daemon.log -i /var/log/syslog
will have the same files split across the vertical axis.
As said earlier, multitail can also tail the output of commands. In a nutshell, to do this, you will need to use -l in place of -i and -L instead of -I.
$ multitail -l "ping 184.108.40.206" -ec 'time=4[0-9]\.?[0-9]* ms' -L "ping 220.127.116.11"
Will ping 18.104.22.168 and ping 22.214.171.124 simultaneously and merge the outputs within the same window. On top of that, we will highlight the chunks of output that match time=4[0-9]\.?[0-9]* ms, e.g any ping's which RTT is between 40 and 50ms.
There is much more possibilities offered by multitail. As always, the manpage is the source of truth. The developer has gathered a few example on his example page.