linux 清除缓存脚本
#!/bin/bash
used=`free -m | awk 'NR==2' | awk '{print $3}'`
free=`free -m | awk 'NR==2' | awk '{print $4}'`
echo "==================================" >> /home/script/mem.log
date >> /home/script/mem.log
echo "Memory usage | [ Used:${used}MB ] [ Free:${free}MB ]" >> /home/script/mem.log
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
fi