Linux: How to do an 'effective' "tail -f" on multiple files?

Sometimes it would be really useful if you could, in real time, join all the log files (/var/log/* in my distro.) and do a tail -f on them except the ones you exclude from a directory (e.g. .bz2 files).

Has anyone tackled this idea and come up with a solution? I would really like to do this and it's especially useful on new hardware when something weird is going wrong and you are not yet sure where.

Who is Participating?
+1 for multitail!

On my system (which has .1 files as the most recent backup, and .n.gz for previous backups) I used:

multitail --mergeall --follow-all -D $(ls -F --ignore="*.bz2" --ignore="[bw]tmp" --ignore="lastlog" --ignore="*.1" --ignore "*.gz"|egrep -v "/$|@$")

Open in new window

It does a "tail -f" of all of the files which don't match any of the exclude patterns, and aren't directories or symlinks.

This example doesn't put the filename at the start of the line -  I'm sure it's possible but I couldn't see how.
There is MultiTail ...
RegProctorAuthor Commented:
Obviously I mean in one command on one command line, not with multiple shell windows like I do on occasion.

Some real-time equivalent to a theoretical command like below (which obviously wont work):

cat --exclude='*.bz2' --exclude='something-else' /var/log/*|tail -n 1

Open in new window

(Again, the above is only to ~demonstrate~ what I want to achieve, it won't work.)
cd /var/log
tail -n2 -f $(ls -F --ignore="*.bz2" --ignore="wtmp" --ignore="something-else" |egrep -v "/$|@$")
RegProctorAuthor Commented:
I installed multitail and it's great.

I've added on more ignore for the log directory from @simon3270 comment which was --ignore="*.old" and it worked perfectly.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.