Step1:查看进程id
输入ps或ps -ef
root@TinaLinux:/proc/631/fd# ps
PID USER TIME COMMAND
1 root 0:03 /sbin/procd
...........
631 root 0:06 ./rt_agent
694 root 0:00 [kworker/2:2]
771 root 0:23 /home/upg/fupg
要查看的进程id为631。
Step2:查看标准输出
切换到/proc/<pid>/fd下,如
root@TinaLinux:~# cd /proc/631/fd
root@TinaLinux:/proc/631/fd# ls
0 1 2 3 4 5 6 7 9
目录中的每一项都是一个符号链接,指向打开的文件,数字则代表文件描述符。其中1 = stdout, 2 = stderr,用cat或tail查看即可。
root@TinaLinux:/proc/631/fd# cat 1
E0831 17:44:23.777757 784 mqtt_api.c:159] fupg:: Connect failed, rc 0xb6087ccc
I0831 17:44:23.778110 784 mqtt_api.c:162] fupg:: response->message : CONNACK return code
E0831 17:44:32.586987 784 mqtt_api.c:159] fupg:: Connect failed, rc 0xb6087ccc
I0831 17:44:32.656756 784 mqtt_api.c:162] fupg:: response->message : CONNACK return code
E0831 17:44:41.649714 784 mqtt_api.c:159] fupg:: Connect failed, rc 0xb6087ccc
I0831 17:44:41.650127 784 mqtt_api.c:162] fupg:: response->message : CONNACK return code
375470][ 85 rt_ipc_server.c]g_rt_ipc_cmd begin...
[DBG ][2021-08-31 17:27:41.737][0xb4b75470][ 99 rt_port_at.c]rt_port_impl_at_command cmd: (AT+CEREG?
).
[DBG ][2021-08-31 17:29:29.832][0xb1dff470][ 337 Socket.c]<-D0
[DBG ][2021-08-31 17:44:15.670][0xb1dff470][ 337 Socket.c]<-00
[DBG ][2021-08-31 17:44:15.670][0xb3375470][ 99 rt_port_at.c]rt_port_impl_at_command cmd: (AT+CSQ
).
[DBG ][2021-08-31 17:44:15.680][0xb4b75470][ 202 rt_port_at.c]rt_port_impl_at_command rsp: (
+CEREG: 0,1文章来源:https://www.toymoban.com/news/detail-500316.html
OK
文章来源地址https://www.toymoban.com/news/detail-500316.html
到了这里,关于Linux查看进程运行输出(/proc/<pid>/fd)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!