Using xargs to run a commands from a bash batch file in parallel
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.