Tailing two log files
Solution 1
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)'
Solution 2
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
http://www.vanheusden.com/multitail/
On Ubuntu 10.04: sudo apt-get install multitail
Solution 3
Yep, using the screen
command, you can have 2 bash sessions running on one terminal.
- Run
screen
to get started, - Then type
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).
Related videos on Youtube
Codemwnci
Updated on September 17, 2022Comments
-
Codemwnci over 1 year
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?
-
Jeremy over 13 yearsWell, 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 Kerr about 13 yearsThis doesn't actually use the fifo; you probably want the tail commands to be
tail fileN >> pipeName
.