{"id":659,"date":"2008-04-30T05:37:53","date_gmt":"2008-04-30T10:37:53","guid":{"rendered":"http:\/\/blogs.law.harvard.edu\/hoanga\/2008\/04\/30\/one-way-to-clean-out-a-gazillion-files"},"modified":"2008-04-30T05:37:53","modified_gmt":"2008-04-30T10:37:53","slug":"one-way-to-clean-out-a-gazillion-files-in-a-directory-without-causi","status":"publish","type":"post","link":"https:\/\/archive.blogs.harvard.edu\/hoanga\/2008\/04\/30\/one-way-to-clean-out-a-gazillion-files-in-a-directory-without-causi\/","title":{"rendered":"One way to clean out a gazillion files in a directory without causing the server to hang on IO"},"content":{"rendered":"<p>Had a case where I had some rails app that was using files for its session store and had been running like that for months.  While it was a careless (and dumb) thing to run it that way, we had to do something about it since it was eating up close to 85% of the system partition.  The dumb way to try to do this is below:<\/p>\n<pre>\r\nnice find \/tmp\/ -name 'ruby_sess.*' | xargs -n 100 rm -fv\r\n<\/pre>\n<p>However, the problem is that this causes insanity on IO which is NOT good for a running service.  (Luckily this service was merely important instead of critical)  So, I present to you my quick and dirty script that will clean up all those nefarious ruby sessions files that have run amok for months.<\/p>\n<pre>\r\nwhile true; do\r\n    nice find \/tmp\/ -name 'ruby_sess.*' | head -n 20 | xargs rm -fv; sleep 10\r\ndone\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Had a case where I had some rails app that was using files for its session store and had been running like that for months. While it was a careless (and dumb) thing to run it that way, we had to do something about it since it was eating up close to 85% of the [&hellip;]<\/p>\n","protected":false},"author":703,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1216,1217,260,1099],"tags":[],"class_list":["post-659","post","type-post","status-publish","format-standard","hentry","category-fixes","category-stupid","category-tech","category-unix"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/archive.blogs.harvard.edu\/hoanga\/wp-json\/wp\/v2\/posts\/659","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/archive.blogs.harvard.edu\/hoanga\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/archive.blogs.harvard.edu\/hoanga\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/archive.blogs.harvard.edu\/hoanga\/wp-json\/wp\/v2\/users\/703"}],"replies":[{"embeddable":true,"href":"https:\/\/archive.blogs.harvard.edu\/hoanga\/wp-json\/wp\/v2\/comments?post=659"}],"version-history":[{"count":0,"href":"https:\/\/archive.blogs.harvard.edu\/hoanga\/wp-json\/wp\/v2\/posts\/659\/revisions"}],"wp:attachment":[{"href":"https:\/\/archive.blogs.harvard.edu\/hoanga\/wp-json\/wp\/v2\/media?parent=659"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/archive.blogs.harvard.edu\/hoanga\/wp-json\/wp\/v2\/categories?post=659"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/archive.blogs.harvard.edu\/hoanga\/wp-json\/wp\/v2\/tags?post=659"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}