diff options
Diffstat (limited to 'sup')
-rwxr-xr-x | sup | 18 |
1 files changed, 9 insertions, 9 deletions
@@ -10,9 +10,9 @@ delay=30 times_ran=0 cleanup() { - if [ -n "$pid" ]; then + if [[ -n "$pid" ]]; then echo "killed... $pid" >&2 - kill $pid + kill "$pid" fi exit } @@ -75,23 +75,23 @@ done command=("$@") while :; do - times_ran=$(($times_ran+1)) - if [ $times_ran -gt $delay_after ]; then - echo "sleeping for $delay seconds after $(($times_ran-1)) runs in $delay_reset_after seconds" >&2 - sleep $delay + times_ran=$((times_ran+1)) + if [[ $times_ran -gt $delay_after ]]; then + echo "sleeping for $delay seconds after $((times_ran-1)) runs in $delay_reset_after seconds" >&2 + sleep "$delay" fi - time_started=`date +%s` + time_started=$(date +%s) echo -n "running... " >&2 - ${command[@]} & + "${command[@]}" & pid=$! echo PID: $pid >&2 wait $pid pid="" # reset counter if run long enough - if [ $(($time_started+$delay_reset_after)) -lt `date +%s` ]; then + if [[ $((time_started+delay_reset_after)) -lt $(date +%s) ]]; then times_ran=0 fi done |