[英]Run multiple python scripts in different terminals
I have multiple python scripts task1.py
and task2.py
.我有多个 python 脚本
task1.py
和task2.py
。 I want to run them simultaneously but in different Terminal windows on MAC OS.我想在 MAC OS 上的不同终端 windows 上同时运行它们。 I have tried
我努力了
python task1.py &
python task2.py &
but the two python scripts run in the same Terminal window, which makes it difficult to check the process.但是两个 python 脚本运行在同一个终端 window 中,这使得检查进程变得困难。
how to do that?怎么做?
I want to run them simultaneously but on a different Terminal
我想同时运行它们,但在不同的终端上
In that case, you can either open a new terminal, which is ok.在这种情况下,您可以打开一个新终端,这没关系。 The shortcut is Shift + Ctrl + T , and then click the + sign.
快捷方式是Shift + Ctrl + T ,然后单击+号。 I prefer the use of iTerm on Mac.
我更喜欢在 Mac 上使用iTerm 。
Or, even better, you can use screen .或者,更好的是,您可以使用screen 。
Run the python1 script in a screen session.在屏幕 session 中运行 python1 脚本。 And the 2nd in another screen session.
另一个屏幕中的第二个 session。
Some basic commands:一些基本命令:
# start a screen session
screen -S <name_your_screen>
#list screens sessions
screen -list
# attach to screen session
screen -r <pid>.<name_of_screen>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.