<?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>SysAdmin Valley &#187; logs</title>
	<atom:link href="http://www.sysadminvalley.com/tag/logs/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sysadminvalley.com</link>
	<description>I might as well write this stuff down so I remember it tomorrow</description>
	<lastBuildDate>Wed, 25 Jan 2012 15:06:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Excluding files in FIND results</title>
		<link>http://www.sysadminvalley.com/2010/03/09/excluding-files-in-find-results/</link>
		<comments>http://www.sysadminvalley.com/2010/03/09/excluding-files-in-find-results/#comments</comments>
		<pubDate>Tue, 09 Mar 2010 19:31:09 +0000</pubDate>
		<dc:creator>mshields</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[logs]]></category>
		<category><![CDATA[mini how-to]]></category>

		<guid isPermaLink="false">http://www.sysadminvalley.com/?p=195</guid>
		<description><![CDATA[Find is one of my favorite little tools under linux.  It helps me &#8220;find&#8221; almost anything, I can find files older than a certain date, newer than a certain date, modified on a certain date.  I can find files that have a certain name, or match a part of a name, file extension.  Once I&#8217;ve [...]]]></description>
			<content:encoded><![CDATA[<p>Find is one of my favorite little tools under <a target="_blank" href="http://www.beantownsoftware.com/linux.html?node=96394&rattr=operating_systems-red_hat">linux</a>.  It helps me &#8220;find&#8221; almost anything, I can find files older than a certain date, newer than a certain date, modified on a certain date.  I can find files that have a certain name, or match a part of a name, file extension.  Once I&#8217;ve found what I&#8217;ve been looking for I can have find do something with those files like delete them or gzip them.</p>
<p>My latest &#8220;find&#8221; with the find command came about because on one of my JBoss servers I wrote a simple script that looks for log files older than 15 days and deletes them and looks for other log files older than 61 minutes and compresses them with gzip.</p>
<blockquote><p>#!/bin/bash<br />
LOGS=/usr/local/jboss/server/all/log/<br />
#delete all logs older than 37 days<br />
find $LOGS -mtime +15 | xargs rm -rf<br />
# gzip files last modify at least 1 hour ago<br />
find $LOGS -mmin +61 | xargs gzip</p></blockquote>
<p>Our JBoss setup automatically writes new logs to server.info.log and server.error.log, then every every hour it renames the INFO and ERROR log to the current date + hour, so server.info.log would be changed to server.info.log.2010-03-09-13 for today at 2pm to roll out the 1pm logs.</p>
<p>The problem I came across in my script was with my server.error.log file.  If an error hasn&#8217;t been written to the server.error.log file during that hour, it wasn&#8217;t going to rotate an empty error log.  Since the file hadn&#8217;t been touched/updated/modified in over 61 minutes, my script came along and gzipped it, at this point JBoss then had a problem because the error log was missing and didn&#8217;t create a new one.</p>
<p>So what I needed to do was to find all the files that matched the criteria, but exclude the server.info.log and server.error.log and here is my final script.</p>
<blockquote><p>#!/bin/bash<br />
LOGS=/usr/local/jboss/server/all/log/<br />
INFOLOG=&#8221;server.info.log&#8221;<br />
ERRORLOG=&#8221;server.error.log&#8221;<br />
#delete all logs older than 37 days<br />
find $LOGS -mtime +15 -not -name &#8220;$INFOLOG&#8221; -not -name &#8220;$ERRORLOG&#8221; | xargs rm -rf<br />
# gzip files last modify at least 1 hour ago<br />
find $LOGS -mmin +61 -not -name &#8220;$INFOLOG&#8221; -not -name &#8220;$ERRORLOG&#8221; | xargs gzip</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.sysadminvalley.com/2010/03/09/excluding-files-in-find-results/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

