Tail multiple files in CentOS


I want to tail multiple files (and follow them) in CentOS, I've tried this:

tail -f file1 file2 file3

but the output is very unfriendly

I've also had a look at multitail but can't find a CentOS version.

What other choices do I have?

By : Hintswen


You can use the watch command, i use it to tail two files at the same time:

watch -n0 tail -n30 file1 file2

A better answer to an old question...

I create a shell function in my .bashrc (obviously assumes you're using bash as your shell) and use tmux. You can probably complicate this a whole lot and do it without the tempfile, but the quoting is just ugly if you're trying to ensure that files with spaces or other weird characters in the name still work.

multitail ()

    echo "new-session -d \"tail -f '$1'\"" >$cmdfile

    for file in "[email protected]"
        echo "split-window -d \"tail -f '$file'\"" >>$cmdfile

    echo "select-layout even-vertical" >>$cmdfile
    tmux source-file $cmdfile \; attach && rm -f $cmdfile
By : ccosby

I found the solution described here work well on centos:

The link is http://www.thegeekstuff.com/2009/09/multitail-to-view-tail-f-output-of-multiple-log-files-in-one-terminal/

Thanks to Ramesh Natarajan

    $ vi multi-tail.sh

    # When this exits, exit all back ground process also.
    trap 'kill $(jobs -p)' EXIT

    # iterate through the each given file names,
    for file in "[email protected]"
        # show tails of each in background.
        tail -f $file &

    # wait .. until CTRL+C
By : Kiran

This video can help you solving your question :)
By: admin