UNIX95= ps -e -o "user,vsz,pid,ppid,args" | sort -rnk2 | head
———–
#!/bin/sh # memtop - show top memory users and pid # VSZ is in KB # echo "VSZ(KB) PID RUSER COMMAND" UNIX95= ps -e -o 'vsz pid ruser args' |sort -nr|head -30
Then this one for a process:
# cat processmem #!/bin/sh # processmem - display memory claimed by a process # # if [ $# -lt 1 -o ( $# -gt 1 -a $# -lt 4 ) ] then echo "Usage:" echo "processmem "process"" echo "Example:" echo "processmem rpc" exit 1 fi echo " " PROCESS=$1 mps=0 #for sz in `ps -elf | grep $PROCESS | grep -v grep | awk '{print $10}'` for sz in `UNIX95= ps -e -o vsz=Kbytes -o ruser -o pid,args=Command-Line | sort -rnk1 | grep -v Kbytes | grep $PROCESS | awk '{print $1}'` do mps=`expr $mps + $sz` done #echo `expr $mps * 4096` echo "nMemory claimed by $PROCESS: $mps Kbytes.n"