I have 3 shell scripts a.sh, b.sh and c.sh. the scripts a.sh and b.sh are to be run parallely and script c.sh should only run if a.sh and b.sh are run successfully ( with exit code 0).
Below is my code. The parallel execution is working fine but sequential execution of c.sh is out of order. It is executing after completion of a.sh and b.sh even if both the scripts are not returning exit codes 0. Below is the code used.
#!/bin/sh
A.sh &
B.sh &
wait &&
C.sh
How this can be changed to meet my requirement?
waitutility is invoked with no operands, it shall wait until all process IDs known to the invoking shell have terminated and exit with a zero exit status" (my emphasis). Therefore, you need towaitfor each separately to get the background processes' exit statuses.