Requirements Analysis:
Suppose we have three processes A and B and C, each corresponding to three run script a.sh,b.sh,c.sh.
A and B two processes are completely independent.
C process must wait until both the A and B processes are finished before the C processes can be started.
We now need to write a script to run these three program scripts
Workaround:
"Not ideal" in series:
View Plain
- a.sh;
- b.sh;
- c.sh;
But if these three processes are going to run for a particularly long time, if 10 hours or so.
In this way, the total time required to run is 30 hours.
Because we know that A and B are independent of each other, we should connect A and B in parallel and then in series with C.
The uptime is optimized to 20 hours.
In parallel we can not use the way in the background, if you run A or B in the background, C needs to wait for a and B to run the end before starting, but C do not know when a and B when the end.
The simplest way to think about it temporarily is to "introduce the parallel command to solve ":
View Plain
- Parallel-j 2 "sh a.sh" "Sh b.sh";
- SH c.sh
In this way A and b are paralleled by parallel, and when both A and B are finished, the parallel command runs.
And then the C program. (To meet our requirements)
Linux command parallel for multi-process parallel computing