Search code examples
bashshellgnu-parallel

Running Multiple Bash Scripts parallel


I want to run multiple bash scripts in parallel.

example of my script running : ./test1.sh $1 and ./test2.sh $1

I tried this: parallel ::: "~/path/test1.sh $1" "~/path/test2.sh $1"

Not working properly, any idea how to fix this?


Solution

  • You could use xargs:
    echo "~/path/test1.sh $1 ~/path/test2.sh $1" | xargs -P0 -n2 /bin/bash

    -P0 says "run all in parallel"
    -n2 passes two arguments to /bin/bash, in this case the script and the parameter