When checking which processes are running on your Oracle Linux instance you can use the ps command. Most likely the ps command is the most likely the most used command to find processes, and for good reasons as it is very easy to use. However, when you want some more insight and a more easy view what is related to what the pstree option can be very useable.
pstree shows running processes as a tree. The tree is rooted at either pid or init if pid is omitted. If a user name is specified, all process trees rooted at processes owned by that user are shown. pstree visually merges identical branches by putting them in square brackets and prefixing them with the repetition count. As an example you can see the below standard output of pstree without any additional options specifief;
As you can see in the above example httpd is between brackets and 10 is mentioned. Which means that 10 which indicates that more processes are running as httpd. Below is shown a part of the full tree (removed the lower part for readability):
This shows the main process (PID 3612) and all other processes that are forked from this process. Using pstree is primarily (in my opinion) to support you when doing some investigation on a machine and is not by default the best tool to use when scripting solutions on Oracle Linux. Having stated that, it is a great tool to use.
pstree shows running processes as a tree. The tree is rooted at either pid or init if pid is omitted. If a user name is specified, all process trees rooted at processes owned by that user are shown. pstree visually merges identical branches by putting them in square brackets and prefixing them with the repetition count. As an example you can see the below standard output of pstree without any additional options specifief;
[root@ce tmp]#
[root@ce tmp]# pstree init─┬─VBoxService───7*[{VBoxService}] ├─acpid ├─crond ├─dhclient ├─httpd───10*[httpd] ├─java───26*[{java}] ├─java───47*[{java}] ├─java───35*[{java}] ├─java───29*[{java}] ├─java───46*[{java}] ├─memcached───5*[{memcached}] ├─6*[mingetty] ├─ntpd ├─2*[rsyslogd───3*[{rsyslogd}]] ├─2*[sendmail] ├─slapd───5*[{slapd}] ├─sshd───sshd───sshd───bash───sudo───su───bash───pstree └─udevd───2*[udevd] [root@ce tmp]#
[root@ce tmp]#
As you can see in the above example httpd is between brackets and 10 is mentioned. Which means that 10 which indicates that more processes are running as httpd. Below is shown a part of the full tree (removed the lower part for readability):
[root@ce tmp]# pstree -p init(1)─┬─VBoxService(1182)─┬─{VBoxService}(1185) │ ├─{VBoxService}(1186) │ ├─{VBoxService}(1187) │ ├─{VBoxService}(1188) │ ├─{VBoxService}(1189) │ ├─{VBoxService}(1190) │ └─{VBoxService}(1191) ├─acpid(1130) ├─crond(1275) ├─dhclient(984) ├─httpd(3612)─┬─httpd(3616) │ ├─httpd(3617) │ ├─httpd(3618) │ ├─httpd(3619) │ ├─httpd(3620) │ ├─httpd(3621) │ ├─httpd(3622) │ ├─httpd(3623) │ ├─httpd(5020) │ └─httpd(5120) ├─java(3993)─┬─{java}(3996) │ ├─{java}(3997) │ ├─{java}(3998)
This shows the main process (PID 3612) and all other processes that are forked from this process. Using pstree is primarily (in my opinion) to support you when doing some investigation on a machine and is not by default the best tool to use when scripting solutions on Oracle Linux. Having stated that, it is a great tool to use.
No comments:
Post a Comment