如何在 Linux 中读取任意进程的标准输出管道?

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

我有一个通过 Supervisor 启动的子进程,它以某种方式与其父进程断开连接并且正在运行但不再输出到父进程的日志文件。

但是,它仍在运行,并且大概仍在写入其标准输出。我怎么读这个?

我找到了 pid,如果我检查

/proc/$pid/fd
我得到:

$ sudo ls -lah /proc/$pid/fd
total 0
dr-x------ 2 root root  0 Mar  5 21:01 .
dr-xr-xr-x 9 root root  0 Mar  5 21:01 ..
lr-x------ 1 root root 64 Mar  5 21:01 0 -> 'pipe:[83894068]'
l-wx------ 1 root root 64 Mar  5 21:01 1 -> 'pipe:[83894069]'
l-wx------ 1 root root 64 Mar  5 21:01 2 -> 'pipe:[83894070]'

如何访问输出管道并从

tail
或其他进程读取它以读取其输出?

linux pipe stdout
© www.soinside.com 2019 - 2024. All rights reserved.