I want to execute a command when a process dies. I already have a solution, but I want to see if there is a better way to do this as a way to further educate BASH. Here is what I have:
$ ps -e | grep scp
7673 pts/1 00:01:17 scp
$ while [ $( ps 7673 2>&1 >/dev/null; echo $? ) = 0 ]; do sleep 1; done; echo "Scp doesn't exist any more"
This works, and I saw uglier solutions. :-) Do you have improvements in this or another more elegant solution?
user14070
source
share