Last updated on June 8, 2020 by Dan Nanni
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.
multitail
on LinuxTo 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
multitail
In the following, I illustrate several common use cases of multitail
command.
The terminal screen will automatically be split into the number of log files specified.
$ sudo multitail --follow-all /var/log/auth.log /var/log/kern.log /var/log/syslog
Use "-s N
" option to vertically split the screen into N
columns.
$ sudo multitail -s 3 --follow-all /var/log/auth.log /var/log/kern.log /var/log/syslog
Besides tailing log files, multitail
can also monitor the output of an external command whiles the execution of the command is in progress. For this, use "-l "command-to-run"
" option. 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"
This website is made possible by minimal ads and your gracious donation via PayPal or credit card
Please note that this article is published by Xmodulo.com under a Creative Commons Attribution-ShareAlike 3.0 Unported License. If you would like to use the whole or any part of this article, you need to cite this web page at Xmodulo.com as the original source.
Xmodulo © 2021 ‒ About ‒ Write for Us ‒ Feed ‒ Powered by DigitalOcean