Skip to content

Instantly share code, notes, and snippets.

@tomsaleeba
Created March 9, 2018 00:23
Show Gist options
  • Save tomsaleeba/ac3332e8f4c147a51a60cf2bbecef3f1 to your computer and use it in GitHub Desktop.
Save tomsaleeba/ac3332e8f4c147a51a60cf2bbecef3f1 to your computer and use it in GitHub Desktop.
BASH wait command demo
#!/usr/bin/env bash
# short demo on how to wait for multiple jobs
echo 'start'
sleep 2 &
job1=$!
echo "do things that don't require job 1 output"
sleep 4 &
job2=$!
echo "do things that don't require job 2 output"
wait $job1
echo 'do things that depend on job 1'
wait $job2
echo 'do things that depend on job 1 AND job 2'
echo 'end'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment