RHEL7 清理内存缓存、缓冲区和SWAP
RHEL7.4 清理内存缓存、缓冲区和交换空间
新建脚本
vim drop_caches.sh chmod +x drop_caches.sh
添加
#!/bin/bash total=`free -m |grep Mem|awk '{print $2}'`; threshold=`expr $total \* 30 \/ 100`; #30% while [ 1 ] do free=`free -m |grep Mem |awk '{print$4}'`; if [ $free -lt $threshold ] then logger -t drop_cache "free memory:"$free" threshold:"$threshold sync sysctl -w vm.drop_caches=3 fi sleep 15 date done
执行脚本
nohup /root/drop_caches.sh > /root/drop_caches.log 2>&1 &
执行前
执行后
本站所有文章均可随意转载,转载时请保留原文链接及作者。