自动释放内存shell脚本
#!/bin/bash mem_total=`free -m | awk 'NR==2' | awk '{print $2}'` mem_free=`free -m | awk 'NR==2' | awk '{print $4}'` mem_used=`free -m | grep Mem | awk '{print $3}'` if (($mem_used != 0)); then mem_per=0`echo "scale=3;$mem_free/$mem_total" | bc` DATE="$(date -d "today" +"%Y-%m-%d-%H-%M") free percent is : $mem_per" echo $DATE >>/var/log/mem_detect.log mem_warn=0.06 mem_now=`expr $mem_per \> $mem_warn` if (($mem_now == 0)); then sync echo 1 > /proc/sys/vm/drop_caches fi fi
原文链接:https://88hzy.cn/6383.html,转载请注明出处。
请先
!