Created
September 13, 2019 15:25
-
-
Save bhurlow/21362b39579fc1f0d1b0401affeb05fc to your computer and use it in GitHub Desktop.
async bash example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
cust_func(){ | |
echo "Do something $1 times..." | |
sleep 1 | |
} | |
# For loop 5 times | |
for i in {1..5} | |
do | |
sleep 5 & | |
# cust_func $i & # Put a function in the background | |
done | |
jobs | |
## Put all cust_func in the background and bash | |
## would wait until those are completed | |
## before displaying all done message | |
wait | |
echo "All done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment