Clear RAM Cache on Linux
1. Clear PageCache only.
sync; echo 1 > /proc/sys/vm/drop_caches
2. Clear dentries and inodes.
sync; echo 2 > /proc/sys/vm/drop_caches
3. Clear PageCache, dentries and inodes.
sync; echo 3 > /proc/sys/vm/drop_caches
Clear swap space on Linux
swapoff -a && swapon -a
Clear RAM cache and swap space via cronjob
Step 1: Create file cronclear.sh:
Clear RAM cache only
#!/bin/bash # Note, we are using "echo 3", but it is not recommended in production instead use "echo 1" echo 3 > /proc/sys/vm/drop_caches
Clear RAM cache and swap space
#!/bin/bash # Note, we are using "echo 3", but it is not recommended in production instead use "echo 1" echo 3 > /proc/sys/vm/drop_caches && swapoff -a && swapon -a
Step 2: Then chmod this file
chmod 755 cronclear.sh
Step 3: crontab -e. Example, you run cronjob daily at 10am
0 10 * * * /path/to/cronclear.sh
1 Comment
Linux: how to fix error: ./configure: line 2710: 25372 Segmentation fault | Free Online Tutorials
(August 15, 2020 - 1:19 am)[…] Now, clear ram cache: Clear RAM cache and swap space on Linux […]