Mac uses pstree to show the process tree
source link: https://www.pkslow.com/archives/mac-pstree-en
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Install
Install the pstree
with brew
:
$ brew install pstree
Show the help doc:
$ pstree --help
pstree: illegal option -- -
pstree $Revision: 2.39 $ by Fred Hucht (C) 1993-2015
EMail: fred AT thp.uni-due.de
Usage: pstree [-f file] [-g n] [-l n] [-u user] [-U] [-s string] [-p pid] [-w] [pid ...]
-f file read input from <file> (- is stdin) instead of running
"ps -axwwo user,pid,ppid,pgid,command"
-g n use graphics chars for tree. n=1: IBM-850, n=2: VT100, n=3: UTF-8
-l n print tree to n level deep
-u user show only branches containing processes of <user>
-U don't show branches containing only root processes
-s string show only branches containing process with <string> in commandline
-p pid show only branches containing process <pid>
-w wide output, not truncated to window width
pid ... process ids to start from, default is 1 (probably init)
Process group leaders are marked with '='.
Samples
Show the tree with the process name:
$ pstree -s terraform
-+= 00001 root /sbin/launchd
\-+= 50669 larry /Users/larry/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/213.5744.223/IntelliJ ID
\-+= 51403 larry /bin/bash --rcfile /Users/larry/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/213
\-+= 55301 larry terraform apply
\--- 55302 larry /Users/larry/Software/terraform/terraform apply
Show the tree with the process ID(Both parent and child process):
$ pstree -p 55301
-+= 00001 root /sbin/launchd
\-+= 50669 larry /Users/larry/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/213.5744.223/IntelliJ ID
\-+= 51403 larry /bin/bash --rcfile /Users/larry/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/213
\-+= 55301 larry terraform apply
\--- 55302 larry /Users/larry/Software/terraform/terraform apply
Show the tree with the process ID(child process):
$ pstree 55301
-+= 55301 larry terraform apply
\--- 55302 larry /Users/larry/Software/terraform/terraform apply
Code for all: GitHub
欢迎关注微信公众号<南瓜慢说>,将持续为你更新...
Recommendations:
Cloud Native
Terraform
Container: Docker/Kubernetes
Spring Boot / Spring Cloud
Https
如何制定切实可行的计划并好好执行
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK