LoginSignup
0
0

More than 5 years have passed since last update.

bashでリトライ処理(だんだんsleep時間を増やす)

Last updated at Posted at 2017-03-02
#!/bin/bash

retry_count=5
retry_interval_seconds=10

count=1
while :
do
  command
  status=$?
  if [ ${status} -eq 0 ]; then
    exit 0
  fi
  if [ ${count} -eq ${retry_count} ]; then
    break
  fi
  sleep_seconds=$((count * retry_interval_seconds))
  count=$((count + 1))
  echo Retry after ${sleep_seconds} seconds, next count is ${count}
  sleep ${sleep_seconds}
done

echo Retry over
exit 1

厳密なExponential Backoffではない

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0