Shell script to view Linux memory usage

  
                  

In Linux, the /proc/$PID/status file provides usage of the process resources (memory, stack, semaphore, child-parent), although Linux provides a lot of commands for viewing memory, but Looking at the overall usage, you cannot view the memory usage of a single process.

This article provides the script for everyone to view the memory usage of the system or process by viewing the VmRSS field in the status file. A friend in need may refer to it.

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 do if [ -d $DOCNAME ]; then cd $DOCNAME if [ - f status ];then MEMERY=`grep VmRSS status

Copyright © Windows knowledge All Rights Reserved