How to Watch For a Process to End on Ubuntu Linux

I wanted to send myself a text when a long running process was done so I needed a command that would watch for a process to end. These commands will watch for a the pid id 1528 to stop running, then echo. Just replace the echo statement with whatever you want to happen when it’s done.

When the process finished

(while kill -0 1528; do sleep 1; done); echo "finished"

Only when the process finished successfully

(while kill -0 1528; do sleep 1; done) && echo "finished successfully"