Created
April 24, 2013 06:39
-
-
Save shurain/5450093 to your computer and use it in GitHub Desktop.
Watch for a particular pid and execute the command when the given process terminates. Useful when used together with notification system. $ ./waitforit.sh [PID] [CMD]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
delay=5 | |
pid=$1 | |
cmd=$2 | |
status="0" | |
while [ "$status" == "0" ] | |
do | |
sleep $delay | |
ps -p$pid 2>&1 > /dev/null | |
status=$? | |
done | |
#The process has started, do something here | |
$cmd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment