Skip to content

Instantly share code, notes, and snippets.

@vmirly
Created November 16, 2013 02:38
Show Gist options
  • Select an option

  • Save vmirly/7495201 to your computer and use it in GitHub Desktop.

Select an option

Save vmirly/7495201 to your computer and use it in GitHub Desktop.
Run a new job after an already running job finishes
# assume that job1.sh is already running
# we want to start jab2.sh right after job1.sh finishes
pid=$(ps -o pid= -C job1.sh)
while [ -d /proc/$pid ]; do
echo "process $pid still running"
sleep 60
done && ./job2.sh
@vmirly
Copy link
Author

vmirly commented Nov 16, 2013

for ps. -o is an output specifier, which here it tells ps that we only want the pid
and -C specifies the command

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment