How to clean up swap, buffer and cache in Linux

  
                

buffer and cache are the cache of the Linux server, and the swap partition occupancy rate will affect the system when it is too high, so the Linux system should be cleaned up in time. The following small series will introduce you how to clean up the Linux system. Swap, buffer and cache, let's learn together.

swap Cleanup:

code is as follows:

swapoff -a & & swapon -a

Note: this cleaning there is a premise Condition, free memory must be larger than the swap space already used

cache cleanup:

The code is as follows:

sync; sync; sync; && echo3 》/Proc/sys/vm/drop_caches

sleep 2

echo 0》/proc/sys/vm/drop_caches

To free pagecache:

Code below :

echo 1 》/proc/sys/vm/drop_caches

To free dentries and inodes:

The code is as follows:

echo 2 》/proc /sys/vm/drop_caches

To free pagecache,dentries and inodes:

The code is as follows:

echo 3 》 /proc/sys/vm/drop_caches
< The value of /proc/sys/vm/drop_caches defaults to 0 (so we will restore it to 0 after we empty it)

The above is the way to clean up swap, buffer and cache in Linux system. Introduced, the cleaning of swap is Preconditions, and regularly clean swap, buffer is also necessary.

Copyright © Windows knowledge All Rights Reserved