I want to write a shell scripts that executes a few commands and waits for all of them to terminate.
I think what I would have to do is use
cmd1 &
cmd2 &
cmd3 &
....
etc.
but what I don’t know is how to wait for them to terminate.
any ideas?
This question has the answer to your problem. 🙂
You would simply
waitfor all running jobs by calling thewaitcommand.How to wait in bash for several subprocesses to finish and return exit code !=0 when any subprocess ends with code !=0?