<?xml version="1.0" encoding="UTF-8"?> <rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
> <channel><title>gHacks Technology News &#124; Latest Tech News, Software And Tutorials &#187; multitail</title> <atom:link href="http://www.ghacks.net/tag/multitail/feed/" rel="self" type="application/rss+xml" /><link>http://www.ghacks.net</link> <description>A technology news blog covering software, mobile phones, gadgets, security, the Internet and other relevant areas.</description> <lastBuildDate>Sat, 11 Feb 2012 09:52:46 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <atom:link rel="hub" href="http://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="http://superfeedr.com/hubbub"/> <item><title>Follow multiple log files with multitail</title><link>http://www.ghacks.net/2009/06/04/follow-multiple-log-files-with-multitail/</link> <comments>http://www.ghacks.net/2009/06/04/follow-multiple-log-files-with-multitail/#comments</comments> <pubDate>Thu, 04 Jun 2009 19:09:25 +0000</pubDate> <dc:creator>Jack Wallen</dc:creator> <category><![CDATA[Advice]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[Open Source]]></category> <category><![CDATA[Security]]></category> <category><![CDATA[Software]]></category> <category><![CDATA[Tutorials Basic]]></category> <category><![CDATA[log files]]></category> <category><![CDATA[multitail]]></category> <category><![CDATA[tail]]></category> <guid
isPermaLink="false">http://www.ghacks.net/2009/06/04/follow-multiple-log-files-with-multitail/</guid> <description><![CDATA[Any Linux administrator knows that watching log files is key to troubleshooting problems on a Linux system. In some troubleshooting instances it is necessary to follow more than one log file. For this you will wind up with two terminal windows open which can become a mess (when you already have a number of windows [...]]]></description> <content:encoded><![CDATA[<p>Any Linux administrator knows that watching log files is key to troubleshooting problems on a Linux system. In some troubleshooting instances it is necessary to follow more than one log file. For this you will wind up with two terminal windows open which can become a mess (when you already have a number of windows open.) With the multitail application it is possible to follow more than one log file in the same window. It&#8217;s a wonderful tool for anyone who has to troubleshoot a Linux machine.</p><p>Multitail does exactly as it sounds &#8211; it allows more than one instance of the tail command in a single window. Given that we should probably take a look at the tail command first.</p><p><span
id="more-13306"></span><strong>Tail</strong></p><p>What tail does is print the output of a log file in real time. With this you can open up, say, <strong>/var/log/messages</strong> with tail and see the last ten lines of that file as they are printed.  This comes in very handy when you need to see the errors precisely as they happen.</p><p>To run the tail command on a log file (we&#8217;ll stick with our example above) you would issue the command:</p><p><em>tail -f /var/log/messages</em></p><p>You would see printed the last ten kernel buffer messages as they are added. This is very helfpul when you are plugging in a USB device and you want to find out what address the device is attached to.</p><p>But what if you want to view, say, <strong>/var/log/mail.err </strong>and <strong>/var/log/mail.warn</strong> together? Sure you could open up two terminals and issue the tail commands for each log file, but why do that when you can have them in the same window?</p><p><strong>Getting and installing multitail</strong></p><p>The easiest way to install multitail is to issue the command (since you&#8217;ll be working in the command line anyway):</p><p><em>sudo apt-get install multitail</em></p><p>or</p><p><em>yum install multitail</em></p><p>Once the application is installed you are ready to go (there is no configuration necessary).</p><p><strong>Running multitail</strong></p><p>The structure of the multitail command is:</p><p>multitail -i FIRSTLOG -i SECONDLOG</p><p>Where FIRSTLOG and SECONDLOG are the log files you want to follow. Sticking with the example above let&#8217;s follow mail.err and mail.info. We do this with the command:</p><p><em>sudo multitail -i /var/log/mail.err -i /var/log/mail.info</em></p><div
id="attachment_13302" class="wp-caption alignleft" style="width: 310px"><a
href="http://www.ghacks.net/wp-content/uploads/2009/06/multitai.png"><img
class="size-medium wp-image-13302" src="http://www.ghacks.net/wp-content/uploads/2009/06/multitai-500x326.png" alt="Figure 1" width="300" height="196" /></a><p
class="wp-caption-text">Figure 1</p></div><p>The above command will have multitail following both log files horizontally (as shown in Figure 1). At first it can be a bit disconcerting to see and follow. What you are seeing is the <strong>/var/log/mail.err</strong> file being tail&#8217;d on top and the <strong>/var/log/mail.info</strong> file being tail&#8217;d on bottom. The easiest way to discern one from the other is at the bottom of each tail is the white bar showing what file is being tail&#8217;d.</p><p>If you do not like the horizontal layout you can change that to a vertical layout with the <em>s</em> switch like so:</p><p><em>sudo multitail -s 2 -i /var/log/mail.err -i /var/log/mail.info</em></p><div
id="attachment_13305" class="wp-caption alignright" style="width: 310px"><a
href="http://www.ghacks.net/wp-content/uploads/2009/06/multitail_v.png"><img
class="size-medium wp-image-13305" src="http://www.ghacks.net/wp-content/uploads/2009/06/multitail_v-500x326.png" alt="Figure 2" width="300" height="196" /></a><p
class="wp-caption-text">Figure 2</p></div><p>When you run this version of the command the tail&#8217;s are side by side with a wide vertical bar between them (as you can see in Figure 2).</p><p><strong>Merging logs</strong></p><p>You can also use multitail to merge multiple logs into one log. This can help you when you know you need to follow the output of more than one log file but you don&#8217;t need them separated. To do this you use the <em>mergeall</em> option like so:</p><p><em>sudo multitail &#8211;mergeall -i /var/log/mail.err -i /var/log/mail.info</em></p><p><strong>Final thoughts</strong></p><p>Multitail is one of those tools that once you get used to having it in your toolkit you will pull it out again and again.</p> ]]></content:encoded> <wfw:commentRss>http://www.ghacks.net/2009/06/04/follow-multiple-log-files-with-multitail/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>
