Find which service process created worker processes.
Display the process hierarchy with PIDs.
Which command is appropriate?
pstree -p displays processes in parent-child tree form and includes each PID.
Detailed explanation
ps -p treeIncorrect. ps -p expects a PID list; tree is not the process-tree option in this form.
pstree -pCorrect. pstree -p shows the process hierarchy and PIDs.
pgrep --parent-allIncorrect. pgrep has no --parent-all option for this display.
uptime -pIncorrect. uptime reports system uptime and load.
Try it yourself
An example you can run in a temporary verification environment.
pstree -p $$ | headExpected result
現在shellを起点としたprocess treeKey points
- pstree
- PPID
- -p
Notes
- Environment: psmisc系pstree
- Use a disposable process or test shell when checking lifecycle commands.
- Exact output and option names can vary slightly by distribution and tool version.
Foundation review
Place the operation
A process tree explains creation relationships; it is different from a flat process listing or a load monitor.
Check the side effect
Start at a known PID or shell when the complete process tree is too large to interpret.