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 /sample.pl 4228 /usr/bin/java -server -cp /sample.java
Linux doesn’t seem to have an equivalent. I’ve tried using “pstree” and “ps -auxf” and others without much success.
pstree seems fine for this.
$ pstree -p 3281 nginx(3281)─┬─nginx(3282) ├─nginx(3283) ├─nginx(3284) ├─nginx(3285) ├─nginx(3286) └─nginx(3287)
-s to see parents:
$ pstree -p -s 3287 systemd(1)───nginx(3281)───nginx(3287)
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.