安裝pstree:yum install psmisc -ylinux
做用:用於追蹤子進程的父進程nginx
使用場景:須要知道某個子進程的父進程時;bash
經常使用選項:app
-a:顯示命令行選項(即顯示啓動進程所使用的命令)
ide
-p:打印出父進程的pid號
spa
-s:顯示子進程全部的父進程(默認只顯示子進程的第一個父進程)
命令行
注:aps常組合在一塊兒使用
進程
用法示例:it
只顯示某個進程的父進程 [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)