Created
February 1, 2021 18:17
-
-
Save RodrigoDornelles/4e4721187f80a767a2a9126545950ce8 to your computer and use it in GitHub Desktop.
clear memory cache linux
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
if [ `whoami` != 'root' ] | |
then | |
echo "[!] Error: requires root!"; | |
exit; | |
fi | |
echo " * Clearing ram PageCache"; | |
sync; | |
echo 1 > /proc/sys/vm/drop_caches; | |
echo " * Clearing ram dentries and inodes"; | |
sync; | |
echo 2 > /proc/sys/vm/drop_caches; | |
echo " * Clearing disk swap"; | |
sync; | |
swapoff -a && swapon -a; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment