Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6331855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:09:03+00:00 2026-05-24T18:09:03+00:00

We do over 20 deployments a day using capistrano (actually webistrano ) and we

  • 0

We do over 20 deployments a day using capistrano (actually webistrano) and we have a problem where the disk space on our servers get full of old deployment folders.

Every now and again I run the deploy:cleanup task to clean out all deployments (it keeps the last :keep_releases, currently set to 30). I would like to automate the cleanup.

One solution would be to add the following to the recipe to automatically run the cleanup after every deployment:

after "deploy", "deploy:cleanup"

But, I don’t want to do this after every deployment, I’d like to limit it to only when the number of previous deployments gets to a threashold, e.g. 70. Does anyone know how I can do this?


Thoughts:

  • Does Capistrano provide a variable that holds the number of previous deployments?
    • If not, does anyone know a way to calculate it. i.e. set :num_releases, <what-can-I-put-here-to-count-previous-deployments>
  • Is there a way to pimp deploy:cleanup so it uses a minimum threshold, i.e. exit if < :max_releases previous deployments (where :max_releases is different from :keep_releases).
  • Could the except keyword be used? i.e. something like :except => { :num_releases < 70}.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T18:09:05+00:00Added an answer on May 24, 2026 at 6:09 pm

    Does Capistrano provide a variable that holds the number of previous deployments?

    Yes, releases.length

    Is there a way to pimp deploy:cleanup so it uses a minimum threshold?

    Yes, here is a privately namespaced task that will trigger the normal cleanup task ONLY if a certain number of release folders have built up:

    namespace :mystuff do
      task :mycleanup, :except => { :no_release => true } do
        thresh = fetch(:cleanup_threshold, 70).to_i
        if releases.length > thresh
          logger.info "Threshold of #{thresh} releases reached, runing deploy:cleanup."
          deploy.cleanup
        end
      end
    end
    

    To have this run automatically after a deploy, put this at the top of the recipe:

    after "deploy", "mystuff:mycleanup"
    

    The good thing about this is that, before and after directives set on deploy:cleanup are executed as normal. For example we require the following:

    before 'deploy:cleanup', 'mystuff:prepare_cleanup_permissions'
    after 'deploy:cleanup', 'mystuff:restore_cleanup_permissions'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Over the last few months/years, I have shared a folder or two with numerous
Over the years as I have gone through school and been working in the
Over the years, I have tried many times to find a good, easy to
Over the years I have slowly developed a regular expression that validates most email
Over the years, I think I have seen and tried every conceivable way of
Over the last few days I have noted a few web sites that demonstrated
Over in this question, Scott writes that it is possible to get the current
Over the years most web developers will have built an arsenal of tools or
I have a deployment project which will not let me install over an older
When I try to install over a previous version I get the error The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.