Tail Multiple Logs At Once

      by Wyatt Walter

I discovered a little trick today that I will probably be using every day. I wasn’t sure exactly which log file I needed to be watching while a coworker was doing some work on a server. There was a lot of log files in a directory and I had no idea what file I was looking for, so I decided to try: “tail -f *.log”. The output was actually very useful. Whenever tail shows output from a different file, it gives you the filename in a tag and shows the output and looked something like this:

tail -f /var/log/*.log
==> /var/log/mail.log <==
Jan 7 23:15:48 apu zmmailboxdmgr[21716]: status requested
Jan 7 23:15:48 apu zmmailboxdmgr[21716]: status OK
==> /var/log/zimbra.log <==
Jan 7 23:15:48 apu zmmailboxdmgr[21716]: status requested
Jan 7 23:15:48 apu zmmailboxdmgr[21716]: status OK
==> /var/log/auth.log <==
Jan 7 23:15:49 apu sudo: zimbra : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/opt/zimbra/libexec/zmmailboxdmgr status
Jan 7 23:15:49 apu sudo: pam_unix(sudo:session): session opened for user root by (uid=0)
Jan 7 23:15:49 apu sudo: pam_unix(sudo:session): session closed for user root

Those are some of the Zimbra logs and it shows the filename inbetween ==> and <==. I'd done the same with grep before, but hadn't thought of using tail in that way. You can also select a couple of files by doing something like this:

tail -f log1.log log2.log

Happy log parsing!

Related Posts Related Websites

Tags:
Filed under How-Tos / Tips : Comments (0) : Jan 8th, 2009

Leave a Reply