LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   What is the Linux equivalant commands of Solaris' prstat & ptree? (https://www.linuxquestions.org/questions/linux-newbie-8/what-is-the-linux-equivalant-commands-of-solaris-prstat-and-ptree-786907/)

parunachalam 02-04-2010 04:43 AM

What is the Linux equivalant commands of Solaris' prstat & ptree?
 
Hi Folks,
Could someone advise the solaris' equivalant commands of prstat & ptree in Linux flavour.

Thanks for your time !

Arun

slacker_et 02-04-2010 10:10 AM

I believe the Linux commands you are looking for are top and pstree.

--ET

MadeInGermany 12-08-2011 06:25 PM

[Just discovered this great forum]

I found the ps -H option useful,
but missed the Solaris filter options, so had to add it.
Here is my ptree for Linux:

#!/bin/sh
# Solaris style ptree
# by Michael Tosch

[ -x /usr/bin/ptree ] && exec /usr/bin/ptree "$@"

# Print process tree
# $1 = PID : extract tree for this process
# $1 = user : filter for this (existing) user
# $1 = user $2 = PID : do both

PATH=/bin:/usr/bin:/usr/sbin:/sbin
export PATH

psopt="-e"
case $1 in
[a-z]*) psopt="-u $1";shift;;
esac

[ -z "$1" ] &&
exec ps $psopt -Ho pid=,args=

#some effort to add less to the ps list
tmp=/tmp/ptree.$$
trap 'rm $tmp' 0 HUP INT TERM
ps $psopt -Ho pid=,args= >$tmp
<$tmp awk '
{ ci=index(substr($0,7),$2); o[ci]=$0 }
ci>s[a] { s[++a]=ci }
$1==pid {
for(i=1;i<=a;i++) {
si=s[i]; if(si<=ci) print o[si]
}
walkdown=ci
next
}
ci<walkdown { exit }
walkdown!=0 { print }
' pid="$1"


All times are GMT -5. The time now is 09:27 PM.