I need some directions for the following issue.
I have 6 processes that I need to run. These are PHP files that I need to spawn from shell script. I am able to do it but the results are not what I want.
The sequence of execution is given below.
- Process1 needs to be submitted and unless it completes process 2 to process 5 cannot be submitted.
- Process 2 to process 5 can be submitted in parallel.
- Process final needs to be submitted after process 2 to process 5 are completed.
I have searched various pages but am unable to find a resolution to it. The pages I have referenced are given below.
https://unix.stackexchange.com/questions/76717/bash-launch-background-process-and-check-when-it-ends
Waiting for background processes to finish before exiting script
Whatever I did following the above links, all the process gets submitted at the same time. Please guide me. The code is given below.
#!/bin/sh
start=`date +%s`
php /usr/share/nginx/html/cron/complete-api-fetch.php user_id=6 process_name=process1
wait
php /usr/share/nginx/html/cron/complete-api-fetch.php user_id=6 process_name=process2
php /usr/share/nginx/html/cron/complete-api-fetch.php user_id=6 process_name=process3
php /usr/share/nginx/html/cron/complete-api-fetch.php user_id=6 process_name=process4
php /usr/share/nginx/html/cron/complete-api-fetch.php user_id=6 process_name=process5
wait
php /usr/share/nginx/html/cron/complete-api-fetch.php user_id=6 process_name=final
end=`date +%s`
runtime=$((end-start))
echo "$runtime"
Please be cognizant that I am newbie and do not know much about the shell process.
Will appreciate any directions and feedback.
Thanks