01 March 2013

How to Clean Cache in Linux

Open a command shell and type 
  • echo 1 > /proc/sys/vm/drop_caches 
    followed by "Enter" to free the pagecache.

  • Type
  • echo 2 > /proc/sys/vm/drop_caches
  • to free up the dentries and inodes. 

  • Type
  • echo 3 > /proc/sys/vm/drop_caches
  • to clear pagecache, dentries and inodes at the same time. It is necessary to clear them in this order so the cache doesn't fill back up.

  • Type 
  • sync; echo 3 > /proc/sys/vm/drop_caches
  • and press "Enter." This clears the entire cache, freeing up a significant amount of memory. 
  • In Ubuntu Linux, this command is 
  • sudo sh -c "sync; echo 3 > /proc/sys/vm/drop_caches"
  • No comments: