linux 清除缓存脚本

Posted sunju

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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:$usedMB ] [ Free:$freeMB ]" >> /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

以上是关于linux 清除缓存脚本的主要内容,如果未能解决你的问题,请参考以下文章