Last active
March 7, 2020 12:42
-
-
Save ftonato/49ed346128c2f269093001fa086cbb44 to your computer and use it in GitHub Desktop.
./clearcache.sh < 1 | 2 | 3 >
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
#!/bin/bash | |
# Note, we are using "echo 3", but it is not recommended in production instead use "echo 1" | |
LEVEL=${1:-1} # If variable not set or null, use "1". | |
shift $(( $# > 0 ? 1 : 0 )) | |
# Check LEVEL is invalid then set to default "1" | |
if [ "$LEVEL" -gt 3 ]; then | |
LEVEL=1 | |
fi | |
# 1 - Free pagecache, dentries and inodes in cache memory | |
# 2 - Free dentries and inodes use following command | |
# 3 - Free pagecache only use following command | |
echo "echo $LEVEL > /proc/sys/vm/drop_caches" | |
exit 0 |
Author
ftonato
commented
Mar 7, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment