Using xargs to run a commands from a bash batch file in parallel

This post was written by eli on December 27, 2013
Posted Under: Linux

Suppose that we have a file, batch-commands.sh, which consists of independent commands to be executed, one for each line. Now we want to run several of these in parallel.

xargs -P 8 -n 1 -d "\n" -a batch-commands.sh bash -c

With -P 8 there are 8 processes running all the time.

Add a Comment

required, use real name
required, will not be published
optional, your blog address