I have a command CMD called from my main bourne shell script that takes forever.
I want to modify the script as follows:
#/bin/bash #pgm to monitor tail -f /var/log/messages >> /tmp/log& # background cmd pid pid=$! # loop to monitor running background cmd while : do ps ax | grep $pid | grep -v grep ret=$? if test "$ret" != "0" then echo "Monitored pid ended" break fi sleep 5 done wait $pid echo $?