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

posted @ 2019-07-08 22:06  a戴姆勒  阅读(553)  评论(0编辑  收藏  举报