Wednesday, April 27, 2022

[SOLVED] How do you run multiple programs in parallel from a bash script?

Issue

I am trying to write a .sh file that runs many programs simultaneously

I tried this

prog1 
prog2

But that runs prog1 then waits until prog1 ends and then starts prog2...

So how can I run them in parallel?


Solution

To run multiple programs in parallel:

prog1 &
prog2 &

If you need your script to wait for the programs to finish, you can add:

wait

at the point where you want the script to wait for them.



Answered By - psmears
Answer Checked By - Katrina (WPSolving Volunteer)