从一个python文件在不同的终端/控制台中运行多个python文件 [英] Running multiple python files in different terminals/consoles from one python file
问题描述
我有5个python文件,我需要在不同的终端/控制台上运行.目前,我正在做的是在自己的终端机/控制台上运行每个文件 python filename.py
.
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.
推荐答案
如果实际上没有必要弹出五个不同的终端,则可以使用screen命令.编写如下的bash脚本:
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
然后,您可以使用例如
screen -r screen-name-1
有关详细信息,请参见 https://www.rackaid.com/blog/linux-screen-tutorial-and-how-to/
For details, see https://www.rackaid.com/blog/linux-screen-tutorial-and-how-to/
这篇关于从一个python文件在不同的终端/控制台中运行多个python文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!