Skip to content

Instantly share code, notes, and snippets.

@rberrelleza
Created June 7, 2013 21:14
Show Gist options
  • Save rberrelleza/5732456 to your computer and use it in GitHub Desktop.
Save rberrelleza/5732456 to your computer and use it in GitHub Desktop.
bash script to kil and wait until it exits
#!/bin/bash
ps aux | grep $1 | grep -v grep | grep -v gone.sh
if [ $? -eq 0 ]; then
#kill -9 $(ps aux | grep $1 | grep -v grep | awk '{ print $2 }')
process=$(ps aux | grep $1 | grep -v grep | grep -v gone.sh | awk '{ print $2 }')
kill $process
fi
is_gone=0
while [ $is_gone -ne 1 ]
do
sleep 1
ps aux | grep $1 | grep -v grep | grep -v gone.sh
is_gone=$?
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment