Nifty Log Watching Command

Have you ever wanted to watch all the logs in /var/log and sub-directories on your Linux box? Well, I have, and normally I just use tail -f *.log, but that doesn’t work because some log files don’t end in “.log”. Furthermore, you can’t use tail -f * because some of the files can contain non-printable binary data (like .gz files), which would mess up your terminal. So, I whipped out this little command today to find all the text files in /var/log (and sub-directories too) and run tail -f on them:

find /var/log | xargs file | grep text | cut -f 1 -d : | xargs tail -F

When just about anything happens on your Linux box, you’ll see it in near real time with this bad boy. Oh, and you’ll probably need to run it as root or at least use sudo.

Edit: I used tail -F instead of tail -f so tail will notice if the log file gets rotated out from under us (thanks Byron).


Write a Reply or Comment

Your email address will not be published.