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 <maximun-number-of-process-at-a-time> -n <arguments per process> <commnad>
Details here.