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?
Yes, tail outputs lines appended to all the files given on the command line:
Have a look at MultiTail. It's your friend.
You can have the multiple log tails in
http://www.vanheusden.com/multitail/
On Ubuntu 10.04:
sudo apt-get install multitail
Yep, using the
screen
command, you can have 2 bash sessions running on one terminal.screen
to get started,Ctrl-a
thenS
(NOTE: capital S) to split the screen into 2.Ctrl-a
thenTab
will move you between the two sessions.Ctrl-a
thenc
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).
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
when finished