#!/bin/bash
set -e
usage() {
cat <<EOF
Usage: $(basename "$0") n command

Runs command every n seconds until it fails, at which point it
promptly propagates the failure.
EOF
}

if [[ $# -lt 2 ]]; then
    usage "$0"
    exit 1
fi

n=$1
shift

while : ; do
    "$@"
    sleep "$n"
done
