Clear memory cache every 5 seconds

Create a shell script using bash.

$ vim

while true
 sync; echo 3 > /proc/sys/vm/drop_caches
 sleep 5

Set execute permissions

$ chmod u+x

Now, execute this shell script in the background using “nohup” as shown below. This will keep executing the script even after you logout from your session. This will execute your shell script every 5 seconds.

$ nohup ./ &

Leave a Reply

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