3

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
python abc.py p1 p4
python xyz.py p2 p3 

where p1, p2, p3 and p4 can be of any type.

I need to run both of these python commands in parallel and in two different terminals. How can I do it so that I don't need to wait for 1 command to finish in order to start the next command?

I tried GNU parallel but it doesn't seem to work.

2

2 Answers 2

3

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 finish
echo "Script done running"

More Info

Sign up to request clarification or add additional context in comments.

1 Comment

Remember a final "wait"
0

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

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.