In Linux, the/proc/$PID/status file provides the usage of the process resources (memory, stack, semaphore, child parent process), although Linux provides a lot of commands to view memory, but it's all about the overall usage and cannot view the memory usage of a single process.
This article provides you with this script, by looking at the Vmrss field in the status file to see the memory of the system or process used, the need for a friend may refer to.
Copy code:
#! /bin/bash
Echo-n "Pidname" >/ROOT/SCRIPT/PID.F
echo "Memery" >>/ROOT/SCRIPT/PID.F
pidpath=/proc/
Totle=0
CD $PIDPATH
doc= ' ls '
For DocName in $DOC
Todo
If [-D $DOCNAME]; Then
CD $DOCNAME
If [F Status];then
Memery= ' grep vmrss status | Awk-f ': ' {print $} ' | awk ' {print '} '
Pidname= ' grep Name status | Awk-f ': ' {print $} '
if [$MEMERY]; Then
Echo-n $PIDNAME >>/ROOT/SCRIPT/PID.F
Echo-n "" >>/ROOT/SCRIPT/PID.F
echo $MEMERY >>/ROOT/SCRIPT/PID.F
totle= ' expr $TOTLE + $MEMERY '
Cd..
Else
Cd..
Fi
Else
Cd..
Fi
Fi
Done
totle= ' expr $TOTLE/1024 '
echo "Totle userd: $TOTLE MB" >>/ROOT/SCRIPT/PID.F
Cat/root/script/pid.f