【问题标题】:Run multiple python scripts in different terminals在不同的终端运行多个 python 脚本
【发布时间】:2022-01-08 04:36:43
【问题描述】:

我有多个 python 脚本 task1.pytask2.py。我想在 MAC OS 的不同终端窗口中同时运行它们。我试过了

python task1.py &
python task2.py &

但是这两个python脚本运行在同一个终端窗口,这使得检查进程变得困难。

怎么做?

【问题讨论】:

  • 你能打开两个单独的终端窗口吗? cmd+n
  • @DNy 我可以,但我实际上有 50 个程序,我想自动运行所有代码。

标签: python bash macos terminal


【解决方案1】:

我想同时在不同的终端上运行它们

在这种情况下,您可以打开一个新终端,这没关系。 快捷键是Shift+Ctrl+T,然后点击+符号。我更喜欢在 Mac 上使用 iTerm

或者,更好的是,您可以使用screen

在屏幕会话中运行 python1 脚本。以及另一个屏幕会话中的第二个。

一些基本命令:

# start a screen session
screen -S <name_your_screen>

#list screens sessions
screen -list

# attach to screen session
screen -r <pid>.<name_of_screen>

另一种方法是使用tmux

【讨论】:

    猜你喜欢
    • 2020-05-27
    • 1970-01-01
    • 1970-01-01
    • 2014-09-08
    • 2018-01-08
    • 2017-06-14
    • 1970-01-01
    • 2020-12-21
    相关资源
    最近更新 更多