释放LINUX CACHEC的 小脚本

#!/bin/bash

used=`free -m | awk 'NR==2' | awk '{print $3}'`
free=`free -m | awk 'NR==2' | awk '{print $4}'`
echo "=====free caches======================="
echo "===http:/blog.csdn.net/zengmuansha======"
date
free -m
echo "====ram disk============================"
df -h |head -1;df -h | grep /dev/shm
echo "====free mem < 100Mb then free caches===="


echo " "
echo "Memory usage | [Use:${used}MB][Free:${free}MB]"


if [ $free -le 100 ] ; then
                sync && echo 1 > /proc/sys/vm/drop_caches
                sync && echo 2 > /proc/sys/vm/drop_caches
                sync && echo 3 > /proc/sys/vm/drop_caches
                echo "OK" >> /var/log/mem.log
else
                echo "Not required" >> /var/log/mem.log
fi

echo " if free after :"
free -m

echo "=======ram disk=============="
df -h |head -1;df -h | grep /dev/shm

你可能感兴趣的:(释放LINUX CACHEC的 小脚本)