安裝pstree:yum install psmisc -y
作用:用於追蹤子進程的父進程
使用場景:需要知道某個子進程的父進程時;
常用選項:
-a:顯示命令行選項(即顯示啓動進程所使用的命令)
-p:打印出父進程的pid號
-s:顯示子進程所有的父進程(默認只顯示子進程的第一個父進程)
注:aps常組合在一起使用
用法示例:
只顯示某個進程的父進程 [root@nginx ~]# pstree 57465 app 顯示出父進程並且同時顯示父進程的pid [root@nginx ~]# pstree -p 57465 app(57465) 顯示出所有的父進程 [root@nginx ~]# pstree -s 57465 systemd───containerd───containerd-shim───app───app 顯示出所有父進程並且顯示它們的PID [root@nginx ~]# pstree -sp 57465 systemd(1)───containerd(34739)───containerd-shim(56121)───app(56138)───app(57465) 顯示出所有父進程、顯示它們的PID、顯示它們啓動時所使用的命令 [root@nginx ~]# pstree -asp 57465 systemd,1 --switched-root --system --deserialize 22 └─containerd,34739 └─containerd-shim,56121 -namespace moby -workdir /var/lib/containerd/io.containerd.runtime.v1.linux/moby/6748525d0d3f03c5e9ec89c673417e18833c4d0888cbea9948619265e9378a35 -address /run/containerd/containerd.sock -containerd-binary ... └─app,56138 └─(app,57465)