pstree命令是用于查看进程树之间的关系,即哪个进程是父进程,哪个是子进程,可以清楚的看出来是谁创建了谁。
pstree未找到命令是因为没有安装psmisc
yum install psmisc
#pstree
base:~$ pstree -help pstree: invalid option -- 'e' Usage: pstree [-acglpsStuZ] [ -h | -H PID ] [ -n | -N type ] [ -A | -G | -U ] [ PID | USER ] pstree -V Display a tree of processes. -a, --arguments show command line arguments -A, --ascii use ASCII line drawing characters -c, --compact don't compact identical subtrees -h, --highlight-all highlight current process and its ancestors -H PID, --highlight-pid=PID highlight this process and its ancestors -g, --show-pgids show process group ids; implies -c -G, --vt100 use VT100 line drawing characters -l, --long don't truncate long lines -n, --numeric-sort sort output by PID -N type, --ns-sort=type sort by namespace type (cgroup, ipc, mnt, net, pid, user, uts) -p, --show-pids show PIDs; implies -c -s, --show-parents show parents of the selected process -S, --ns-changes show namespace transitions -t, --thread-names show full thread names -T, --hide-threads hide threads, show only processes -u, --uid-changes show uid transitions -U, --unicode use UTF-8 (Unicode) line drawing characters -V, --version display version information -Z, --security-context show SELinux security contexts PID start at this PID; default is 1 (init) USER show only trees rooted at processes of this user
几个重要的参数:
-a :同时显示参数
-A: 各进程树之间的连接以ASCII码字符来连接
-U:各进程树之间的连接以utf8字符来连接,某些终端可能会有错误
-p:同时列出每个进程的PID
-u: 同时列出每个进程的所属账号名称:
base:~$ pstree systemd─┬─ModemManager───2*[{ModemManager}] ├─NetworkManager─┬─dhclient │ └─2*[{NetworkManager}] ├─accounts-daemon───2*[{accounts-daemon}] ├─agetty ├─atd ├─chronyd ├─containerd─┬─containerd-shim─┬─mysqld───34*[{mysqld}] │ │ └─10*[{containerd-shim}] │ ├─containerd-shim─┬─php-fpm───3*[php-fpm] │ │ └─12*[{containerd-shim}] │ ├─containerd-shim─┬─nginx───8*[nginx] │ │ └─10*[{containerd-shim}] │ ├─containerd-shim─┬─redis-server───3*[{redis-server}] │ │ └─9*[{containerd-shim}] │ └─31*[{containerd}] ├─cron ├─dbus-daemon ├─dockerd─┬─2*[docker-proxy───21*[{docker-proxy}]] │ ├─2*[docker-proxy───5*[{docker-proxy}]] │ ├─docker-proxy───7*[{docker-proxy}] │ └─27*[{dockerd}] ├─irqbalance───{irqbalance} ├─lvmetad ├─lxcfs───4*[{lxcfs}] ├─networkd-dispat───{networkd-dispat} ├─polkitd───2*[{polkitd}] ├─rsync ├─rsyslogd───3*[{rsyslogd}] ├─sshd───sshd───sshd───bash───pstree ├─systemd───(sd-pam) ├─systemd-journal ├─systemd-logind ├─systemd-resolve ├─systemd-udevd ├─tinyproxy───100*[tinyproxy] ├─unattended-upgr───{unattended-upgr} ├─uuidd ├─wpa_supplicant ├─wrapper─┬─java───22*[{java}] │ └─{wrapper} └─zabbix_agentd───5*[zabbix_agentd]
完结