Run python commands in parallel in Linux shell scripting

前端 未结 2 870
-上瘾入骨i
-上瘾入骨i 2021-01-23 00:21

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.         


        
相关标签:
2条回答
  • 2021-01-23 00:59

    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

    0 讨论(0)
  • 2021-01-23 01:02

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

    parallel ::: "python abc.py p1 p4" "python xyz.py p2 p3"
    
    0 讨论(0)
提交回复
热议问题