标签:监测内存的使用率
#!/bin/bashmem=free -m |grep Mem |awk ‘{print $3/$2*100}‘ |awk -F. ‘{print $1}‘
if [ $mem -ge 80 ];then
echo "Memory usage exceeds 80%."
read -p "Do you want to clean up the memory? [y/n] " answer
if [ $answer = y ];then
echo 3 > /proc/sys/vm/drop_caches
echo "Memory cleaning completion."
elif [ $answer = n ];then
echo "Exit."
else
echo "Input error."
fi
else
echo "The rate of use of memory is $mem%."
fi
标签:监测内存的使用率
原文地址:http://blog.51cto.com/13765357/2121355