HOW TO Flush The Linux File Cache

You can’t prevent Linux from using the file cache and you don’t want to. However, on occasion you may want to flush it. Here’s how:

First, flush your filesystems to disk. Just run the command sync

Then, echo 1, 2 or 3 in to /proc/sys/vm/drop_caches. It breaks down like this:

  1. free pagecache: echo 1 > /proc/sys/vm/drop_caches
  2. free dentries and inodes: echo 2 > /proc/sys/vm/drop_caches
  3. free pagecache, dentries and inodes: echo 3 > /proc/sys/vm/drop_caches

Did you find this post useful or have questions or comments? Please let me know!

This entry was posted in How Tos, linux. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *