问题
I have 5 python files which i need to run on different terminals/consoles. Currently what i'm doing is running each file on its own terminal/console python filename.py
.
What i would like is to run one file that will run all the other files in different terminals/consoles.
I haven't tried anything yet. I'm looking for someone to point me in the right direction on what to do.
回答1:
You could use the screen command, if it is not actually necessary that five different terminals pop up. Write a bash script like this:
#!/bin/bash
screen -dmS "screen-name-1" python filename1.py
screen -dmS "screen-name-2" python filename2.py
screen -dmS "screen-name-2" python filename2.py
Then you can access each screen with e.g.
screen -r screen-name-1
For details, see https://www.rackaid.com/blog/linux-screen-tutorial-and-how-to/
来源:https://stackoverflow.com/questions/31217888/running-multiple-python-files-in-different-terminals-consoles-from-one-python-fi