Tail multiple remote files

Solution 1:

My preferred option is to go with multitail. I'd run something like:

multitail -l 'ssh user@host1 "tail -f /some/log/file"' -l 'ssh user@host2 "tail -f /some/log/file"'

Solution 2:

This worked for me:

ssh -n user@hostname1 'tail -f /mylogs/log' &
ssh -n user@hostname2 'tail -f /mylogs/log' &

Solution 3:

You can use fabric to tail several hosts (and also grep results, if needed):

$ fab -P -u 'USER' -p 'PASSWORD' --linewise -H host1,host2,host3 -- tail -f /path/to/my/log.log | grep ERROR

Solution 4:

I was thinking it might also be possible to use:

ssh -f user@hostname1 "tail -f /var/log/file" > /tmp/somefile &
ssh -f user@hostname2 "tail -f /var/log/file" > /tmp/somefile &

The -f option after ssh allows you to enter a password before it runs in the background. Then you could have the line-by-line results in a single file and running:

tail -f /tmp/somefile

Would give you a little more control over the current "tail" command in case you wanted to use other tail options for displaying output.


Solution 5:

Check out this answer on stackoverflow -- it uses dsh and tail -f.