Last active
May 31, 2016 06:35
-
-
Save makeittotop/d8976fa63f617255de8dc987b73cd4bb to your computer and use it in GitHub Desktop.
test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[root@ip-12-0-1-211 httpd]# cat print_process_tree.sh | |
#!/usr/bin/env bash | |
process=$1 | |
pgrep -lf "$process" | head -1 | pstree -p $(cut -d" " -f1); | |
echo 'Total count: ' $(pgrep -lf "$process" | wc -l) | |
[root@ip-12-0-1-211 httpd]# ./print_process_tree.sh ssh | |
sshd(2757)───sshd(2761)───bash(2762)───sudo(2793)───su(2794)───bash(2795)───bash(11445)─┬─pgrep(11446) | |
└─pstree(11448) | |
[root@ip-12-0-1-211 httpd]# ./print_process_tree.sh httpd | |
httpd(6572)─┬─httpd(11348) | |
├─httpd(11361) | |
├─httpd(11375) | |
├─httpd(11378) | |
├─httpd(11401) | |
├─httpd(11426) | |
├─httpd(11432) | |
├─httpd(11433) | |
├─httpd(11434) | |
├─httpd(11435) | |
├─httpd(11437) | |
├─httpd(11438) | |
├─httpd(11439) | |
├─httpd(11440) | |
├─httpd(11441) | |
├─httpd(11442) | |
├─httpd(11443) | |
└─httpd(11444) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment