3

I have an application which generates new log files each time it is run. They all go to one folder, with filenames like this, and the next log isn't started until the current one is finished.

Log-20140122102407.txt
Log-20140122102739.txt
Log-20140122103640.txt
Log-20140122162121.txt
Log-20140122163145.txt

I want to monitor the current progress in a terminal window like tail -f but that won't work with multiple files. I've heard of multitail, but don't know how to use it, and I don't want my terminal window split into multiple sections.

5

tail

tail can tail multiple files. Donovan Bray's article explains more, tail: can tail multiple files simultaneously, who knew? and other tail tricks.

To tail multiple files, pass in a file pattern:

tail -f Log-*

multitail

You can ask multitail to combine the output of multiple files. The examples page contains a useful approaches and tricks.

This command combines and tails two logs:

multitail /var/log/apache/access.log -I /var/log/apache/error.log

If you need to tail any logs in a folder, including those actively being created, use the -q flag:

multitail -q 'test*'

This will tail any files matching the pattern test*, including those that appear after the command has been issued. Thanks to @folkert-van-heusden for this suggestion and code fix.

If you have homebrew installed, you can install multitail using the Terminal.app command:

brew install multitail

See also:

  • 1
    As far as I can tell, neither of those solutions works because it doesn't recognize future log files which are created after the command is entered. – Elliott Jan 23 '14 at 21:35
  • I am not aware of any tool that does this. If your command includes a wildcard * then, you can press 'Command + .' to interrupt tail, press up, and finally press enter to resume logging with the latest files. – Graham Miln Jan 27 '14 at 9:59
  • elliott: have you checked -q and -Q? maybe they are of use? – Folkert van Heusden Feb 11 '14 at 19:40
  • 1
    normally multitail -Q should work in this case but I noticed that it is broken. working on it! – Folkert van Heusden Feb 11 '14 at 20:14
  • 2
    Ok I've fixed it: -q/-Q should now work (in multitail v6.1). Tested by: multitail -q 'test*' and then in an other terminal window: sleep 3 ; echo 1 > test1 ; sleep 3 ; echo 2 > test2 ; sleep 3 ; echo 3 > test3 ; sleep 3 ; etc. – Folkert van Heusden Feb 12 '14 at 21:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .