How To Run Bash Scripts Group By Group?

adil
Aug 23, 2020

I have a bunch of Bash scripts. I separated them into groups of three. The first group has 3 scripts, the second group has 3 scripts, the third group has only 1 script.

The workflow must be like this:

1) The first group should be running at the same time. The second group and the third group shouldn’t be running when the first group is running.

2) The second group should start running once the first group has stopped.

3) The third group should start running once the second group has stopped.

I created a run.sh:

#!/bin/bash
./group1_1.sh &
./group1_2.sh &
./group1_3.sh &
wait
./group2_1.sh &
./group2_2.sh &
./group2_3.sh &
wait
./group3_1.sh &
wait

P.S.: Each script is going to start asynchronously in each group.

--

--