How can I log a linux command's process tree?

wsaxton asked:

I’m trying to track the usage of a certain command so I want to log its parents (to see what is actually using it)

Solaris has “ptree” which would be pretty easy to parse and log:

# ptree 4198
4198  /usr/bin/perl -S /
  4228  /usr/bin/java -server -cp /

Linux doesn’t seem to have an equivalent. I’ve tried using “pstree” and “ps -auxf” and others without much success.

My answer:

pstree seems fine for this.


$ pstree -p 3281

And use -s to see parents:

$ pstree -p -s 3287

View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.