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//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
OK
).
查看内存OOM信息
1.dmesg介绍
在dmesg里我们可以查看到开机信息,printk产生的信息等。若研究内核代码,在代码中插入printk函数,然后通过dmesg观察是一个很好地方法。
2.dmesg输出含义
dmesg 输出的数字含义是什么,纠结了一会儿,下面给出解释
终端输入dmesg,可以看到每行最开始显示的是一个综括号,里面的数字为timestamp,时间戳,该时间指示的系统从开机到现在的运行时间,单位为s 秒。
图1
3.dmesg -c
在显示的同时,clean掉dmesg缓存中信息
4.dmesg -T
以当前时间的方式显示时间信息,而不是图1所示的开机时间
图2
3 dmesg -d
显示dmesg中两条打印信息的时间间隔
图3
我们可以计算,上一行的时间戳 + 下一行的间隔 = 下一行的时间戳
例如:第一行和第二行,1069.638561 + 0.000003 = 1069.638564 这里的时间单位为秒
4.dmesg -d -T
-d和-T参数混合使用,效果可想而知
图4
5.dmesg | tail 显示dmesg最近一次的输出