blob: 31a8c0653cb4a7177f09fe6506d10443cd97bf88 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
#!/bin/sh
trap "kill 0" EXIT
SLEEP_BEFORE_RESPAWN=${SLEEP_BEFORE_RESPAWN:-0}
i=0
max_i=500
while [ $i -lt $max_i ]; do
echo "$i: starting: $*"
$* &
LAST_PID=$!
wait $LAST_PID
echo "$i: stopped pid $LAST_PID with status $?"
if [ $SLEEP_BEFORE_RESPAWN -gt 0 ]; then
echo "sleeping $SLEEP_BEFORE_RESPAWN seconds..."
sleep $SLEEP_BEFORE_RESPAWN
fi
i=$(expr $i + 1)
done
echo "exiting after $max_i runs"
|