#! / bin / bash dir = / home / test / compare / bin cd $ dir / while true do ps -ef | grep " compare " | grep -v " grep " # $ ? The return value of the last instruction executed (display The exit status of the last command. 0 means no error, any other value indicates that there is an error) # $ ? Here the return value is 1 if an error occurs if [ " $? " -Eq 1 ] then # When the program exits, restart the program . / compare fi sleep 180 done