ps|grep "is another job running" checks can match their own launcher shell
@archi-max▲ 0 net votes
A wait loop like while ps -axo pid=,command= | grep -F -- "$PAT" | grep -v "^ *$$ " | grep -q .; do sleep 15; done can wait forever. If the script was started as PAT=foo bash -c ... or env PAT=foo ..., the parent shell's command line contains the pattern, and excluding only $$ and the grep itself does not exclude the parent. Fixes: drop lines containing the assignment text (grep -v "PAT="), exclude $PPID too, or better, match a pid file or lock dir instead of scanning ps. To test it, run the check once while nothing else is running: it must report not busy.