{"id":3399,"date":"2012-03-31T00:00:00","date_gmt":"2012-03-30T22:00:00","guid":{"rendered":"http:\/\/www.theill.com\/blog\/2012\/03\/31\/a-bash-version-of-keep_releases-known-from-capistrano-ruby-scripts\/"},"modified":"2012-03-31T00:00:00","modified_gmt":"2012-03-30T22:00:00","slug":"a-bash-version-of-keep_releases-known-from-capistrano-ruby-scripts","status":"publish","type":"post","link":"https:\/\/www.theill.com\/blog\/2012\/03\/31\/a-bash-version-of-keep_releases-known-from-capistrano-ruby-scripts\/","title":{"rendered":"A bash version of keep_releases known from Capistrano ruby scripts"},"content":{"rendered":"

Today I needed a clean up feature in my bash script similar to what’s known from Capistrano when using the “keep_releases” argument.<\/p>\n

I wasn’t able to find a simple version so I created it myself. Maybe others find it useful too so here goes<\/p>\n

releases_path=\/data\/sites\/yoursite.com\/releases # change this\nkeep_releases=5\n\nversions=`ls -xt $releases_path`\nreleases=(${versions\/\/ \/ })\n\n# check available number of versions in releases directory\nreleases_count=${#releases[@]}\n\nif [ $releases_count -le $keep_releases ]\nthen\n  echo 'no old releases to clean up'\nelse\n  echo keeping $keep_releases of $releases_count deployed releases\n  releases=(${releases[@]:0:0} ${releases[@]:($keep_releases)})\n\n  for release in \"${releases[@]}\"\n  do\n    path=$releases_path$release\n    `rm -rf $path`\n  done\nfi\n<\/code><\/pre>\n

I’ve created a github gist<\/a> too. Feel free to modify it if you have a better solution.<\/p>\n","protected":false},"excerpt":{"rendered":"

Today I needed a clean up feature in my bash script similar to what’s known from Capistrano when using the “keep_releases” argument. I wasn’t able to find a simple version so I created it myself. Maybe others find it useful too so here goes releases_path=\/data\/sites\/yoursite.com\/releases # change this keep_releases=5 versions=`ls -xt $releases_path` releases=(${versions\/\/ \/ }) … Continue reading A bash version of keep_releases known from Capistrano ruby scripts<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"amp_status":"","spay_email":"","jetpack_publicize_message":""},"categories":[1],"tags":[],"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"yoast_head":"\nA bash version of keep_releases known from Capistrano ruby scripts • Peter Theill Site<\/title>\n<meta name=\"robots\" content=\"index, follow\" \/>\n<meta name=\"googlebot\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<meta name=\"bingbot\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.theill.com\/blog\/2012\/03\/31\/a-bash-version-of-keep_releases-known-from-capistrano-ruby-scripts\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"A bash version of keep_releases known from Capistrano ruby scripts • Peter Theill Site\" \/>\n<meta property=\"og:description\" content=\"Today I needed a clean up feature in my bash script similar to what’s known from Capistrano when using the “keep_releases” argument. I wasn’t able to find a simple version so I created it myself. Maybe others find it useful too so here goes releases_path=\/data\/sites\/yoursite.com\/releases # change this keep_releases=5 versions=`ls -xt $releases_path` releases=(${versions\/\/ \/ }) … Continue reading A bash version of keep_releases known from Capistrano ruby scripts\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.theill.com\/blog\/2012\/03\/31\/a-bash-version-of-keep_releases-known-from-capistrano-ruby-scripts\/\" \/>\n<meta property=\"og:site_name\" content=\"Peter Theill Site\" \/>\n<meta property=\"article:published_time\" content=\"2012-03-30T22:00:00+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary\" \/>\n<meta name=\"twitter:creator\" content=\"@theill\" \/>\n<meta name=\"twitter:site\" content=\"@theill\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.theill.com\/#website\",\"url\":\"https:\/\/www.theill.com\/\",\"name\":\"Peter Theill Site\",\"description\":\"What\\u2019s going on in the personal life of Peter Theill\",\"publisher\":{\"@id\":\"https:\/\/www.theill.com\/#\/schema\/person\/d65d009363af2cc0a150b55dc20fa301\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":\"https:\/\/www.theill.com\/?s={search_term_string}\",\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.theill.com\/blog\/2012\/03\/31\/a-bash-version-of-keep_releases-known-from-capistrano-ruby-scripts\/#webpage\",\"url\":\"https:\/\/www.theill.com\/blog\/2012\/03\/31\/a-bash-version-of-keep_releases-known-from-capistrano-ruby-scripts\/\",\"name\":\"A bash version of keep_releases known from Capistrano ruby scripts • Peter Theill Site\",\"isPartOf\":{\"@id\":\"https:\/\/www.theill.com\/#website\"},\"datePublished\":\"2012-03-30T22:00:00+00:00\",\"dateModified\":\"2012-03-30T22:00:00+00:00\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.theill.com\/blog\/2012\/03\/31\/a-bash-version-of-keep_releases-known-from-capistrano-ruby-scripts\/\"]}]},{\"@type\":\"Article\",\"@id\":\"https:\/\/www.theill.com\/blog\/2012\/03\/31\/a-bash-version-of-keep_releases-known-from-capistrano-ruby-scripts\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.theill.com\/blog\/2012\/03\/31\/a-bash-version-of-keep_releases-known-from-capistrano-ruby-scripts\/#webpage\"},\"author\":{\"@id\":\"https:\/\/www.theill.com\/#\/schema\/person\/d65d009363af2cc0a150b55dc20fa301\"},\"headline\":\"A bash version of keep_releases known from Capistrano ruby scripts\",\"datePublished\":\"2012-03-30T22:00:00+00:00\",\"dateModified\":\"2012-03-30T22:00:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.theill.com\/blog\/2012\/03\/31\/a-bash-version-of-keep_releases-known-from-capistrano-ruby-scripts\/#webpage\"},\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.theill.com\/#\/schema\/person\/d65d009363af2cc0a150b55dc20fa301\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.theill.com\/blog\/2012\/03\/31\/a-bash-version-of-keep_releases-known-from-capistrano-ruby-scripts\/#respond\"]}]},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/www.theill.com\/#\/schema\/person\/d65d009363af2cc0a150b55dc20fa301\",\"name\":\"Peter\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/www.theill.com\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/f4f96a08152550e603ee595403f3ba57?s=96&d=retro&r=g\",\"caption\":\"Peter\"},\"logo\":{\"@id\":\"https:\/\/www.theill.com\/#personlogo\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","jetpack_shortlink":"https:\/\/wp.me\/p8TYI1-SP","jetpack-related-posts":[{"id":3404,"url":"https:\/\/www.theill.com\/blog\/2011\/01\/14\/how-to-get-display-name-from-nsscreen\/","url_meta":{"origin":3399,"position":0},"title":"How to get display name from NSScreen","date":"January 14, 2011","format":false,"excerpt":"While working on Wallpapery I needed to get a given screens display name. There is no \u201cdisplayName\u201d method on NSScreen so I added a category to provide this functionality. Seems like others are looking for this too so I\u2019m posting my code below. NSScreen+DisplayName.h #import @interface NSScreen (DisplayName) - (NSString\u2026","rel":"","context":"Similar post","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3410,"url":"https:\/\/www.theill.com\/blog\/2010\/08\/18\/upgraded-shoutsms-from-rails-2-3-8-to-rails-3-in-five-minutes\/","url_meta":{"origin":3399,"position":1},"title":"Upgraded ShoutSMS from Rails 2.3.8 to Rails 3 in five minutes","date":"August 18, 2010","format":false,"excerpt":"Today I wanted to try how easy it would be to upgrade our existing ShoutSMS (pretty small) rails application from 2.3.8 to latest Rails 3 release candidate (currently rc3). Without taking our test suite into consideration it took around five minutes with help from the official rails_upgrade[1] plugin. This is\u2026","rel":"","context":"Similar post","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3405,"url":"https:\/\/www.theill.com\/blog\/2010\/11\/18\/uimodalpresentationformsheet-width-and-height-for-an-ipad-in-landscape-mode\/","url_meta":{"origin":3399,"position":2},"title":"UIModalPresentationFormSheet width and height for an iPad in landscape mode","date":"November 18, 2010","format":false,"excerpt":"In a recent application I was doing, I was designing an interface to be shown as a modal form sheet using setModalPresentationStyle:UIModalPresentationFormSheet. I searched the Apple documentation to find the exact dimensions of this sheet but it isn\u2019t documented. It only states \u201cThe width and height of the presented view\u2026","rel":"","context":"Similar post","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3417,"url":"https:\/\/www.theill.com\/blog\/2009\/03\/16\/upgrading-rails-engines-project-to-rails-2-3-2\/","url_meta":{"origin":3399,"position":3},"title":"Upgrading Rails Engines Project to Rails 2.3.2","date":"March 16, 2009","format":false,"excerpt":"My lifestyleapps project (still in very early beta) was running Rails 2.2.2 with the Rails Engines plugin ten minutes ago. Today, Rails 2.3.2 was released so I decided to try if I could easily upgrade it and avoid using the Rails Engines plugin anymore. It was beautiful simple and took\u2026","rel":"","context":"In "development"","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3406,"url":"https:\/\/www.theill.com\/blog\/2010\/10\/27\/how-to-backup-redmine-on-google-storage\/","url_meta":{"origin":3399,"position":4},"title":"How to backup Redmine on Google Storage","date":"October 27, 2010","format":false,"excerpt":"If you would like to backup your Redmine database and files, you might to consider Google Storage as your backup location. It comes with a 100 GB free monthly usage. First, you need to sign up for a Google Storage account if you don\u2019t have an account already. Once done,\u2026","rel":"","context":"Similar post","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3413,"url":"https:\/\/www.theill.com\/blog\/2010\/05\/03\/an-error-occurred-while-validating-hresult-8001010e\/","url_meta":{"origin":3399,"position":5},"title":"An error occurred while validating. HRESULT = '8001010E'","date":"May 3, 2010","format":false,"excerpt":"Just a quick tip. While upgrading one of my projects from VS.NET 2008 to VS.NET 2010 I ran into a problem I wasn\u2019t able to find a correct solution for it anywhere. While building my setup projects I got: An error occurred while validating. HRESULT = \u20188001010E\u2019 Various posts suggested\u2026","rel":"","context":"In "development"","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_likes_enabled":true,"amp_validity":null,"_links":{"self":[{"href":"https:\/\/www.theill.com\/wp-json\/wp\/v2\/posts\/3399"}],"collection":[{"href":"https:\/\/www.theill.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.theill.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.theill.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.theill.com\/wp-json\/wp\/v2\/comments?post=3399"}],"version-history":[{"count":0,"href":"https:\/\/www.theill.com\/wp-json\/wp\/v2\/posts\/3399\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.theill.com\/wp-json\/wp\/v2\/media?parent=3399"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.theill.com\/wp-json\/wp\/v2\/categories?post=3399"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.theill.com\/wp-json\/wp\/v2\/tags?post=3399"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}