BUFFER / CACHE CLEANING on Linux

Some apps and tools that are installed on Linux Distros, may use high Buffer/Cache RAM. As we know, High RAM consumption may cause Server Shutdown or Hang.


To aviod this situation, we need to configure apps and tools first,
If it does not work, we have a work-around solution as “Buffer/Cache Ram Cleaning”


We can make it happen with the following command with ROOT user

free && sync && echo 3 > /proc/sys/vm/drop_caches && free

Before Buffer/Cache cleaning;
Free Ram was 165 MB, buff/cache Ram was 30880 MB


After cleaning;
Free Ram was 29113 MB, buff/cache Ram was 1991 MB

We can set this operation as a scheduler job with cronjob as down below;
(example; at 8 a.m every day | every hour)


cronjob -e
0 8 * * * free && sync && echo 3 > /proc/sys/vm/drop_caches && free
0 0 * * * free && sync && echo 3 > /proc/sys/vm/drop_caches && free

Comments