是否可以从服务中使用相同的gnome-terminal窗口

问题描述 投票:1回答:1

我能够从我的python服务打开一个终端来拖尾我想要的某个文件。但是,如果有许多文件要按顺序排序,则以下代码将为每个文件启动一个新终端。如何强制始终重用相同的终端窗口?

def tail_logging(title, file_to_tail):
    os.system(
        "DISPLAY=:0.0 XAUTHORITY=/data/.Xauthority gnome-terminal --name 'Todd' -t "
        + title
        + ' -- /bin/bash -c "tail -f '
        + file_to_tail
        + '"'
    )

for i in range(3):
    tail_logging("Same", str(i))

enter image description here

python python-3.x ubuntu-18.04 gnome-terminal
1个回答
0
投票

由于我需要尽快使其工作,这是我的解决方法。我拖到主日志(最初为空)并创建其他进程写入自己的日志以及此主日志。要同时写入两个日志文件,我只需在记录器中创建2个文件处理程序。它工作得很好。我现在可以在同一个终端控制台中看到来自不同进程的日志。

© www.soinside.com 2019 - 2024. All rights reserved.