How To Run Bash Scripts Group By Group?

I have a bunch of Bash scripts. I separated them into groups of three. First group has 3 scripts, second group has 3 scripts, 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.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store