5

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?

6 Answers 6

6

Multitail is available for CentOS in rpmforge repos. To add rpmforge repository check the documentation on 3rd Party Repositories.

1
  • That page said : "RPMForge/RepoForge - This is a dead project. Not maintained. DO NOT USE."
    – simomo
    Sep 14, 2016 at 2:10
3

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
    #!/bin/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 "$@"
    do
        # show tails of each in background.
        tail -f $file &
    done

    # wait .. until CTRL+C
    wait
2

You could simulate multitail by opening multiple instances of tail -f in Emacs subwindows.

1
  • 1
    You could also do the same thing in GNU's screen.
    – brianegge
    May 26, 2009 at 7:06
2

I usually just open another xterm and run a separate 'tail -f' there.

Otherwise if I'm using the 'screen' tool, I'll set up separate 'tail -f' commands there. I don't like that as much because it takes a few keystrokes to enable scrolling in screen before using the Page Up and Page Down keys. I prefer to just use xterm's scroll bar.

1

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

watch -n0 tail -n30 file1 file2

0

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 ()
{
    cmdfile=`mktemp`

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

    for file in "$@"
    do
        echo "split-window -d \"tail -f '$file'\"" >>$cmdfile
    done

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.