<?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>Erics Tech Blog &#187; find</title>
	<atom:link href="http://eric.lubow.org/tag/find/feed/" rel="self" type="application/rss+xml" />
	<link>http://eric.lubow.org</link>
	<description>Thoughts, musings, and other idealistic (sometimes useful) systems and development hoopla.</description>
	<lastBuildDate>Fri, 18 Nov 2011 14:56:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.4</generator>
		<item>
		<title>Thoughts on Blog Posting</title>
		<link>http://eric.lubow.org/2009/misc/thoughts-on-blog-posting/</link>
		<comments>http://eric.lubow.org/2009/misc/thoughts-on-blog-posting/#comments</comments>
		<pubDate>Thu, 19 Nov 2009 12:15:01 +0000</pubDate>
		<dc:creator>eric</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[find]]></category>

		<guid isPermaLink="false">http://eric.lubow.org/?p=358</guid>
		<description><![CDATA[During a conversation I was having with Nirvdrum about blog posts, we got to discussing the validity and credibility of blog posting along with how and why people do it. I have a few thoughts on this topic. The first and foremost reason that I write blog posts is that engineers who spend a lot [...]]]></description>
			<content:encoded><![CDATA[<p>During a conversation I was having with <a href="http://nirvdrum.com/">Nirvdrum</a> about blog posts, we got to discussing the validity and credibility of blog posting along with how and why people do it.  I have a few thoughts on this topic.</p>
<p>The first and foremost reason that I write blog posts is that engineers who spend a lot of time figuring things out on the fly could use a helping hand.  A lot of that figuring is done piecing together parts of other people&#8217;s solutions to problems from various blogs and papers.  Every time I run into an issue or fix a problem, I try to write a blog post about it.  I don&#8217;t do this because I feel that I have more to offer than anyone else, I just feel like my work should be able to benefit others (there is no use in reinventing the wheel).  And to top it off, if I do something and someone has a better way, I like hearing about it in the comments or from an email.<br />
<span id="more-358"></span><br />
My personal preference when writing blog posts is when possible, short and sweet.  Just do what you&#8217;re going to do, explain when necessary, but convey the idea and intention.  If something needs substantiation, context, or proof then give it.  Don&#8217;t just say something like, &#8220;writing your query like XXX will speed it up by 100ms&#8221; without context.  I wrote a lot of queries, that run in hours; 100ms won&#8217;t mean anything to me.  I also am not a huge fan of academic papers or pure blue sky optimistic benchmarks.  Now that&#8217;s not to say that those papers don&#8217;t have their place, but in reality, most situations aren&#8217;t blue sky with unlimited budget and all hardware being equal.</p>
<p>Nirvdrum prefers academic papers with lots of peer review and benchmarks.  Those types of things are great for theory, but in practice, implementing in such circumstances is not the norm.  I typically lump white papers into that group as they tend to be slightly biased towards the companies that prepare them.  White papers are great for ideas for solutions, but I think the real nitty gritty lies in finding the right blog post or posts to help you find your solution.</p>


<p>Related posts:<ol><li><a href='http://eric.lubow.org/2009/misc/busiest-person-you-know/' rel='bookmark' title='Busiest Person You Know'>Busiest Person You Know</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://eric.lubow.org/2009/misc/thoughts-on-blog-posting/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Deleting Lots Of Files (SysAdmin problem solving exercise)</title>
		<link>http://eric.lubow.org/2007/system-administration/deleting-lots-of-files-sysadmin-problem-solving-exercise/</link>
		<comments>http://eric.lubow.org/2007/system-administration/deleting-lots-of-files-sysadmin-problem-solving-exercise/#comments</comments>
		<pubDate>Mon, 17 Dec 2007 11:15:12 +0000</pubDate>
		<dc:creator>eric</dc:creator>
				<category><![CDATA[System Administration]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[find]]></category>
		<category><![CDATA[logrotate]]></category>

		<guid isPermaLink="false">http://eric.lubow.org/blog/2007/system-administration/45/deleting-lots-of-files-sysadmin-problem-solving-exercise/</guid>
		<description><![CDATA[Since I know I am not the first (or the last) to make a typo in logrotate and not catch it for a while&#8230;someone else must have been in the position of having to delete a lot of files in the same manner. I recently learned that, as usual, there is more than one way [...]]]></description>
			<content:encoded><![CDATA[<p>Since I know I am not the first (or the last) to make a typo in logrotate and not catch it for a while&#8230;someone else must have been in the position of having to delete a lot of files in the same manner.  I recently learned that, as usual, there is more than one way to handle it.</p>
<p>To put the situation in context, I basically allowed thousands of <em>mail.*</em> files to be created.  These files littered the <em>/var/log/</em> directory and basically slowed down the entire file system access.  I figured out this a number of ways.</p>
<p>The first way was when I tried to do an <strong>ls</strong> anywhere, it would just hang.  My first reaction was to check to see what was eating up the CPU.  To do this, I did a <strong>top</strong>. I noticed that <strong>logrotate</strong> was hogging all the CPU cycles.  Since I know that <strong>logrotate</strong> basically only operates on one parent directory (by default) <em>/var/log</em>, I headed on over there and did an <strong>ls</strong>.  Once again, it just hung.  Then I figured the file system was slow and decided to check out some file system information.  The next two commands I ran were <strong>df -h</strong> and <strong>df -i</strong>. I ran the <strong>df -h</strong> to see if we were out of disk space (and yes I lazily use human readable format).  I ran the second to check to see how many inodes were in use. (For more information on inodes, check out the <a href="http://en.wikipedia.org/">wikipedia</a> entry <a href="http://en.wikipedia.org/wiki/Inode">here</a>).</p>
<p>Now that I know the system is short on inodes, I checked out the output of <strong>lsof</strong>.  Now I know that we have some serious problems in the <em>/var/log</em> dir.  After some quick investigation, I realized that there were too many <em>mail.*</em> files.  How do I get rid of them? Glad you asked&#8230; Let&#8217;s assume that we want to delete ALL the <em>mail.*</em> files in the <em>/var/log</em> directory.</p>
<p>1) The easiest way is to do it with <strong>find</strong>:<br />
1a) Using <strong>find</strong>&#8216;s delete command:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">[root@eric] /var/log # find ./ -type f -name &quot;mail.*&quot; -delete</div></div>
<p>or<br />
1b) using <strong>find</strong>&#8216;s exec command with <strong>rm</strong>:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">[root@eric] /var/log # find ./ -type f -name &quot;mail.*&quot; -exec rm -rf '{}' \;</div></div>
<p>These will work, but either will be slow since they doesn&#8217;t do batch execution.</p>
<p>2) A slightly more preferred way is to use bash:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">[root@eric] /var/log # for n in mail.*; do rm -v $n; done;</div></div>
<p>This is a little faster, but will still be relatively slow since there is no batch execution. (Note: The -v in the rm will cause quite a bit of output since it is showing you EVERY file it deletes.  Feel free to leave this out if you really screwed up.)</p>
<p>3) The actual preferred method is to use <strong>find</strong>:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">[root@eric] /var/log # find ./ -type f -name &quot;mail.*&quot; | xargs rm -f</div></div>
<p>I believe this is the preferred method because although it removes the files one at a time, it is more efficient for the file system since it batches it up.</p>
<p>There are certainly other ways to accomplish this task.  It can always be done with a Perl one-liner or even using some Perl modules to save some time.  These are just a few ideas to point someone in the right direction.</p>


<p>Related posts:<ol><li><a href='http://eric.lubow.org/2009/ruby/parsing-ini-files-with-ruby/' rel='bookmark' title='Parsing Ini Files With Ruby'>Parsing Ini Files With Ruby</a></li>
<li><a href='http://eric.lubow.org/2007/linux-security/ssh-organization-tips/' rel='bookmark' title='SSH Organization Tips'>SSH Organization Tips</a></li>
<li><a href='http://eric.lubow.org/2007/perl/filefind/' rel='bookmark' title='File::Find'>File::Find</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://eric.lubow.org/2007/system-administration/deleting-lots-of-files-sysadmin-problem-solving-exercise/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

