Start script after another one (already running) finishes Start script after another one (already running) finishes bash bash

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.


Maybe you can press ctrl+z first and enter

fg; echo "first job finished"


Polling is probably the way to go, but it doesn't have to be horrible.

pid=$(ps -opid= -C your_script_name)while [ -d /proc/$pid ] ; do    sleep 1done && ./your_other_script