#!/bin/bash instance=${1:-1} rm -f t.stop i=0 while [ ! -e t.stop ] do A=$(basename /bin/sh) last_exec=$? i=$(( i+1 )) echo "Instance $instance, loop $i, status $last_exec" if [ $last_exec -ne 0 ]; then echo "!!!! ERROR !!!!" touch t.stop exit 1 fi done