How to clear cache in RedHat (linux)

To free some cache memory and (or) dentries and inodes we can use /proc/sys/vm/drop_caches and sync commands:

To free pagecache:

sync; echo 1 > /proc/sys/vm/drop_caches

To free dentries and inodes:

sync; echo 2 > /proc/sys/vm/drop_caches

To free pagecache, dentries and inodes:

sync; echo 3 > /proc/sys/vm/drop_caches

The “sync” command at the beggining will let us be sure that all cached objects are freed.

Leave a Response