Help In Linux

Linux Technical Blog
April 9, 2011

shell script to find linux memory process usage

Hi,

The following script will check for top 20 processes which uses maximum memory resource in the server and will store it in “overusage” file only if the free memory goes below 700MB. Set cron to execute this script whenever needed.

 

 

#!/bin/bash
#High RAM usage checker
r=`free -m |awk 'NR==3' |awk '{ print$4 }'`
if [ $r -lt 700 ];
then
ps -e -orss=,args= | sort -b -k1,1n |tail -n 20 >> overusage
exit
fi


3 Comments to “shell script to find linux memory process usage”

Leave a Comment



Protected by WP Anti Spam