Skip to content

Instantly share code, notes, and snippets.

@bdashrad
Created June 12, 2024 13:55
Show Gist options
  • Select an option

  • Save bdashrad/656d55ffcb515f5d63d70a4529b3565d to your computer and use it in GitHub Desktop.

Select an option

Save bdashrad/656d55ffcb515f5d63d70a4529b3565d to your computer and use it in GitHub Desktop.

Revisions

  1. bdashrad created this gist Jun 12, 2024.
    10 changes: 10 additions & 0 deletions backoff.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    #!/usr/bin/env bash

    # example exponential backoff in bash

    for (( i=0; ; i++)); do
    TIME=$(echo "2^$i" | bc)
    [ $TIME -ge 32 ] && exit 1
    sleep $TIME
    // do stuff && break
    done