Bash: verify that process has stopped
Posted
by
pfac
on Super User
See other posts from Super User
or by pfac
Published on 2013-10-30T14:23:15Z
Indexed on
2013/10/31
16:01 UTC
Read the original article
Hit count: 229
I'm working on script meant to start/stop a set of services. For stopping, it has to terminate many processes which take a while and might hang.
The script needs to verify that the process has indeed terminated, and send an email if such does not happen after a given period.
This is what I have:
pkill -f "stuff"
for i in {1..30}; do
VERIFICATIONS=$i
if verification_command then
echo "It's gone"
break
fi
sleep 2
done
if [ $VERIFICATIONS -ge 30 ]; then
echo "failed to terminate"
# send mail
fi
Is there a better way to do this?
© Super User or respective owner