Running multiple python files in different terminals/consoles from one python file

故事扮演 提交于 2019-12-24 15:32:55

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!