Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 813
  • Last Modified:

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.

Thanks,
Reg
0
RegProctor
Asked:
RegProctor
  • 2
  • 2
2 Solutions
 
woolmilkporcCommented:
There is MultiTail ...

http://www.vanheusden.com/multitail/
0
 
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.)
0
 
woolmilkporcCommented:
cd /var/log
tail -n2 -f $(ls -F --ignore="*.bz2" --ignore="wtmp" --ignore="something-else" |egrep -v "/$|@$")
0
 
simon3270Commented:
+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.
0
 
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.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now