清除Linux OS 缓存

1.查看内存使用情况

[root@ip-172-31-25-243 tpch_2_17_0]# free -m
             total       used       free     shared    buffers     cached
Mem:         34304      34142        162          0         39      20890
-/+ buffers/cache:      13211      21092
Swap:            0          0          0

m代表以MB为单位,显示OS缓存为20890MB

2.释放前最好sync一下,防止丢数据

[root@ip-172-31-25-243 tpch_2_17_0]# sync

3.清除缓存

[root@ip-172-31-25-243 tpch_2_17_0]# echo 1 > /proc/sys/vm/drop_caches

4.查看效果

[root@ip-172-31-25-243 tpch_2_17_0]# free -m
             total       used       free     shared    buffers     cached
Mem:         34304      13168      21135          0          1        541
-/+ buffers/cache:      12626      21678
Swap:            0          0          0

可以看到此时缓存大小减少为541MB

原文地址:https://www.cnblogs.com/littlesuccess/p/5070621.html