Running commands in parallel with a limit of simultaneous number of commands

Posted by Vi on Super User See other posts from Super User or by Vi
Published on 2010-06-17T11:47:04Z Indexed on 2010/06/17 11:54 UTC
Read the original article Hit count: 352

Filed under:
|
|
|

Sequential: for i in {1..1000}; do do_something $i; done - too slow

Parallel: for i in {1..1000}; do do_something $i& done - too much load

How to run commands in parallel, but not more than, for example, 20 instances per moment?

Now usually using hack like for i in {1..1000}; do do_something $i& sleep 5; done, but this is not a good solution.

© Super User or respective owner

Related posts about linux

Related posts about bash