loop

This script will invoke the given script repeatedly with a given delay between invocations and an initial delay.

The loop will finish when the given script has an exit code other than 100.

Usage

with-exit-condition.sh
#!/usr/bin/env sh
if [ ... ]; then
  exit 0 # finish loop
fi
infinite.sh
#!/usr/bin/env sh
exit 100 # infinite loop
$ scripts/general/loop.sh 10 10 some-script.sh
$ scripts/general/loop.sh 5 0 some-otherscript-with-parameters.sh a 1
  • counter

    $ scripts/general/loop.sh 1 0 scripts/general/counter.sh my-counter 5
    12345