Show processes as a tree

The

1
<a href="http://www.bellevuelinux.org/pstree.html">pstree command</a>

shows the ancestral relationships between processes running on a machine. What does that mean? It means you can see an awesome tree of what’s running on your box, instead of the boring output of ps. Check it:

It compresses multiple descendants into a single entry, with the number of descendents (like for apache2 and mysqld here). You can also have it search by user, pid, and more. See the man page for exact details.

Other nice features are being able to highlight certain processes and show command line arguments. So if you wanted to see how the latest apache2 process was called, you could run

pgrep -n apache2 | xargs -I mystr pstree -apH mystr

and get back:

This isn’t a particularly interesting example, but if you knew one of a number of scripts might be causing MySQL to act up, for instance, you could call their names in the pgrep search, and quickly see who called it.

Post to Twitter Post to Delicious Post to Digg Post to Reddit

No related posts.

Related posts brought to you by Yet Another Related Posts Plugin.

This entry was posted in CLI and tagged , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>