Linux cache释放

cache释放:

To free pagecache:

echo 1 > /proc/sys/vm/drop_caches

To free dentries and inodes:

echo 2 > /proc/sys/vm/drop_caches

To free pagecache, dentries and inodes:

echo 3 > /proc/sys/vm/drop_caches

说明,释放前最好sync一下,防止丢数据。

 

附:

linux cache内存释放bash 脚本

#! /bin/sh
    freemem=$(cat /proc/meminfo | grep "MemFree" | awk '{print $2}')
       if [ $freemem -le 40 ]
          then 
               date  >> /var/log/mem.log
               free -m >> /var/log/mem.log
               sync
               sync
               echo 3 > /proc/sys/vm/drop_caches
               free -m >> /var/log/mem.log             
       fi

 


posted @ 2016-12-30 11:06  純黑色  阅读(248)  评论(0编辑  收藏  举报