Create a shell script clearcache.sh and add the following lines. Now we will be creating a shell script to auto clear RAM cache daily at 2 am via a cron scheduler task.
Moreover, it will also slow the system for a few seconds while the cache is cleaned and every resource required by OS is loaded again in the disk cache. If we clean the cache, the disk cache will be less useful as the OS will look for the resource on the disk. If it finds the resource in the cache, then the request doesn’t reach the disk. Linux is designed in such a way that it looks into the disk cache before looking onto the disk.
You can drop cache as explained above without rebooting the System i.e., no downtime required. When you are applying various settings and want to check, if it is actually implemented specially on the I/O-extensive benchmark, then you may need to clear the buffer cache.
Redhat linux free free#
Is it a good idea to free Buffer and Cache in Linux that might be used by Linux Kernel? Free Buffer and Cache in Linux It is not recommended to use the third option above “.echo 3 >” in production until you know what you are doing, as it will clear pagecache, dentries, and inodes. If you have to clear the disk cache, the first command is safest in enterprise and production as “.echo 1 > ….” will clear the PageCache only. As mentioned in the kernel documentation, writing to drop_cache will clean cache without killing any application/service, command echo is doing the job of writing to file. The shell waits for each command to terminate before executing the next command in the sequence. Command Separated by “ ” run sequentially.