{"id":79,"date":"2008-02-21T10:11:40","date_gmt":"2008-02-21T17:11:40","guid":{"rendered":"http:\/\/thesmithfam.org\/blog\/2008\/02\/21\/nifty-log-watching-command\/"},"modified":"2019-08-12T07:16:11","modified_gmt":"2019-08-12T13:16:11","slug":"nifty-log-watching-command","status":"publish","type":"post","link":"https:\/\/thesmithfam.org\/blog\/2008\/02\/21\/nifty-log-watching-command\/","title":{"rendered":"Nifty Log Watching Command"},"content":{"rendered":"<p>Have you ever wanted to watch all the logs in <b>\/var\/log<\/b> and sub-directories on your Linux box? Well, I have, and normally I just use <b>tail -f *.log<\/b>, but that doesn&#8217;t work because some log files don&#8217;t end in &#8220;.log&#8221;. Furthermore, you can&#8217;t use <b> tail -f *<\/b> 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 <b>tail -f<\/b> on them:<\/p>\n<pre>\r\nfind \/var\/log | xargs file | grep text | cut -f 1 -d : | xargs tail -F\r\n<\/pre>\n<p>When just about <b>anything<\/b> happens on your Linux box, you&#8217;ll see it in near real time with this bad boy. Oh, and you&#8217;ll probably need to run it as <b>root<\/b> or at least use <b>sudo<\/b>.<\/p>\n<p>Edit: I used <b>tail -F<\/b> instead of <b>tail -f<\/b> so tail will notice if the log file gets rotated out from under us (thanks <a href=\"http:\/\/theclarkfamily.name\/blog\/\">Byron<\/a>).<\/p>\n<p>Enjoy!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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&#8217;t work because some log files don&#8217;t end in &#8220;.log&#8221;. Furthermore, you can&#8217;t use tail -f * because some of the files can contain non-printable [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-79","post","type-post","status-publish","format-standard","hentry","category-code-and-cruft"],"_links":{"self":[{"href":"https:\/\/thesmithfam.org\/blog\/wp-json\/wp\/v2\/posts\/79","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/thesmithfam.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/thesmithfam.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/thesmithfam.org\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/thesmithfam.org\/blog\/wp-json\/wp\/v2\/comments?post=79"}],"version-history":[{"count":1,"href":"https:\/\/thesmithfam.org\/blog\/wp-json\/wp\/v2\/posts\/79\/revisions"}],"predecessor-version":[{"id":1569,"href":"https:\/\/thesmithfam.org\/blog\/wp-json\/wp\/v2\/posts\/79\/revisions\/1569"}],"wp:attachment":[{"href":"https:\/\/thesmithfam.org\/blog\/wp-json\/wp\/v2\/media?parent=79"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/thesmithfam.org\/blog\/wp-json\/wp\/v2\/categories?post=79"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/thesmithfam.org\/blog\/wp-json\/wp\/v2\/tags?post=79"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}