Skip to content Skip to sidebar Skip to footer

Run Python Commands In Parallel In Linux Shell Scripting

I have a script which gets input from the user through command line arguments. It processes the arguments and starts running python commands. For Example: ./run.sh p1 p2 p3 p4 pyth

Solution 1:

Try running each process in the background by adding & to the end of the command.

python script1.py arg1 arg2 &
python script2.py arg1 arg2 &

echo"Running scripts in parallel"wait# This will wait until both scripts finishecho"Script done running"

More Info

Solution 2:

Your task is not where GNU Parallel excels, but it can be done:

parallel ::: "python abc.py p1 p4""python xyz.py p2 p3"

Post a Comment for "Run Python Commands In Parallel In Linux Shell Scripting"