Start script after another one (already running) finishes

Given the PID of the first process, the loop

while ps -p $PID; do sleep 1; done ; script2

should do the trick. This is a little more stable than pgrep and process names.

Leave a Comment