Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a web application that outputs to a number of log files with performance information. One log file outputs code execution times and another outputs SQL timings. I have no control over the logger or the code that produces the log files, but I want to output the logs in one place.

Currently I am doing something like this

tail -f sqlLogs.log | grep sql-time
tail -f perflogs.log | grep exec-time

This outputs something to the console every time an SQL is executed in the application. But I have to run the code in two separate SSH sessions. However, what I want to be able to tail both files, in the same SSH session. Is this possible?

share|improve this question
up vote 17 down vote accepted

Yes, tail outputs lines appended to all the files given on the command line:

tail -F sqlLogs.log perflogs.log | egrep '(sql-time|exec-time)'
share|improve this answer
Well, that's easier than my way! (lol, just upvoted an answer that's not mine, I'll leave mine up for curiosity's sake) – Jeremy Oct 19 '10 at 8:11

Have a look at MultiTail. It's your friend.

You can have the multiple log tails in

 - different windows, a al vim's 'split'
 - or have it merge the two (or N) streams into one view and
 - you can filter steams by regex and, if you like,
 - it will 'tee' the output to a file

On Ubuntu 10.04: sudo apt-get install multitail

share|improve this answer

Yep, using the screen command, you can have 2 bash sessions running on one terminal.

  • Run screen to get started,
  • Then type Ctrl-a then S (NOTE: capital S) to split the screen into 2.
  • Ctrl-a then Tab will move you between the two sessions.
  • Ctrl-a then c will start a shell in that new region.

(Please see Riccardo's answer before using this, his is much simpler, I'll leave this up as it may be useful for people with similar but different problems).

share|improve this answer

You can use mkfifo to multiplex the output to one pipe

create a fifo pipe, tail n files to the pipe, then cat the pipe

 mkfifo pipeName
 tail file1 &
 tail file2 &
 tail fileN &
 cat pipeName

when finished

 rm pipeName
share|improve this answer
This doesn't actually use the fifo; you probably want the tail commands to be tail fileN >> pipeName. – Jeremy Kerr Feb 25 '11 at 1:51

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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