Tail Multiple Files (Linux)

Tail Multiple Files (Linux)

Posted on 16. Mar, 2010 by forouzani in System Administration

When doing system admin, or even development / deployment on load balanced servers, its always handy to be able to watch the error logs to keep an eye on things and make sure you pick up any issues as soon as possible. The tail command comes in handy, to keep a trailing out of the log file you want to watch on the current server. But what if you want to tail files on multiple servers, all on the same screen? Simple – use aliases.

First we need to assign aliases. This will create shortcuts for our tail commands. Note that we are tailing 3 files – 2 of which are on remote servers.

# alias tail1="tail -f /var/log/httpd/error_log"

# alias tail2="ssh server2 'tail -f /var/log/httpd/error_log'"

# alias tail3="ssh server3 'tail -f /var/log/httpd/error_log'"

Now that we have our aliases setup, we can simple execute them using:

# tail1&tail2&tail3

At this point, we will be watching a continuous stream of tail data, from the files of three different servers.

Tags: , ,

Leave a Reply