I have more than 10 tasks to execute, and the system restrict that there at most 4 tasks can run at the same time.
My task can be started like: myprog taskname
How can I write a bash shell script to run these task. The most important thing is that when one task finish, the script can start another immediately, making the running tasks count remain 4 all the time.
Use xargs
:
xargs -P <maximum-number-of-process-at-a-time> -n <arguments-per-process> <command>
Details here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With