Sha256: ead91d5a6880c6c8e62c7e0407fd1196cf588d247578529df86f94dc7dd91f5d
Contents?: true
Size: 604 Bytes
Versions: 10
Compression:
Stored size: 604 Bytes
Contents
# encoding: utf-8 # This file is distributed under New Relic's license terms. # See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details. module Multiverse module ShellUtils module_function def try_command_n_times(cmd, n, wait_time=1) count = 0 loop do count += 1 result = `#{cmd}` if $?.success? return result elsif count < n sleep wait_time redo else puts "System command: #{cmd} failed #{n} times. Giving up..." return result end end end end end
Version data entries
10 entries across 10 versions & 1 rubygems