I happen to have a ci job consisting of multiple tasks that requires a lot of time. If I run all the tasks synchronously, it will absolutely take a long time. So I am thinking of running them in multiple background processes to save the time.
Run Command in Background Process
To do so, I simply need to add a &
symbol at the end of my command, then my command runs in background process:
1 |
|
Background Process Control
Processes can be controlled and waited by using the pid
:
1 |
|
Waiting for Multiple Processes to Finish
My ci job is to build multiple packages, so I need to wait for all the background processes to finish. To do so, I wrote this script to manage the processes:
1 |
|