def delete_old_temp_folders
      path = File.join(Dir.tmpdir, STAGING_AREA_PREFIX + '*')

      day = 24 * 60 * 60
      dirs = Dir.glob(path)
      dirs.select! { |dir| Time.now.utc - File.ctime(dir).utc > day } # only stale ones
      removed = dirs.each { |dir| FileUtils.rm_rf(dir) }

      log "Removed #{removed} old temp folder(s)" if removed.count > 0
    end
def delete_old_temp_folders
      path = File.join(Dir.tmpdir, STAGING_AREA_PREFIX + '*')

      day = 24 * 60 * 60
      dirs = Dir.glob(path)
      dirs.select! { |dir| Time.now.utc - File.ctime(dir).utc > day } # only stale ones
      removed = dirs.each { |dir| FileUtils.rm_rf(dir) }

      log "Removed #{removed} old temp folder(s)" if removed.count > 0
    end
Sometimes SIGTERM causes Dir.mktmpdir to not properly delete the temp folder
 Remove 1 day old folders