1

I am able to open a terminal from my python service to tail certain file that I want. However, if there are many files that I want to tail sequentially, the following code will launch a new terminal for each file. How do I force to always reuse the same terminal window?

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

juanpa.arrivillaga
  • 88,713
  • 10
  • 131
  • 172
thsieh
  • 620
  • 8
  • 24

1 Answers1

0

Since I need to make it working as soon as possible, here is my workaround. I tail to the master log (initially empty) and make other processes that write to its own log as well as this master log. To simultaneous writing to two log files, I just create 2 file handlers in the logger. It works pretty well. I now can see the logs from different processes in the same terminal console.

thsieh
  • 620
  • 8
  • 24