莫大人

linux 清理缓存buff/cache

清理缓存

echo 1 > /proc/sys/vm/drop_caches
echo 2 > /proc/sys/vm/drop_caches
echo 3 > /proc/sys/vm/drop_caches

  

 

清理脚本 purgeCache.sh

#!/bin/bash

mem_now=`free -m | awk 'NR==2' | awk '{print $4}'`
buff_now=`free -m | awk 'NR==2' | awk '{print $6}'`

if [ $mem_now -le 512 -o $buff_now -ge 2000 ]; then 
      sync
      sleep 10 
      echo 1 > /proc/sys/vm/drop_caches
      echo 2 > /proc/sys/vm/drop_caches
      echo 3 > /proc/sys/vm/drop_caches
      echo "--->release memory OK at $(date +%Y%m%d_%H%M%S)" >> /tmp/purgeCache.log
fi

  

posted on 2019-04-03 14:41  莫大人  阅读(1567)  评论(0编辑  收藏  举报

导航