Skip to content
Snippets Groups Projects
Verified Commit d09b3806 authored by zycromerz's avatar zycromerz
Browse files

update DoDropCache method


Signed-off-by: default avatarZyCromerZ <neetroid97@gmail.com>
parent 276f5429
No related branches found
No related tags found
No related merge requests found
......@@ -573,37 +573,36 @@ DoDropCache(){
local DoDropCacheNow=""
local clearType=""
[[ "$(GetDisplayStatus)" == "off" ]] && [[ "$DropValTime" -le "20" ]] && DropValTime="$(($DropValTime*2))"
if [[ "$(date +"%H")" == "23" ]];then
DropVal="0"
[[ ! -z "$LastDropCache" ]] && LastDropCache=""
else
if [[ -f /proc/sys/vm/drop_caches ]] && [[ "$DropVal" != "0" ]];then
if [[ -z "$LastDropCache" ]];then
DoDropCacheNow="y"
elif [[ "$LastDropCache" -lt "$(AddTime "0")" ]];then
DoDropCacheNow="y"
else
DoDropCacheNow="n"
fi
if [[ "$DropVal" -gt "3" ]];then
DropVal="3"
WriteOnly $DropVal $PMConfig/drop_caches.conf
elif [[ "$DropVal" -lt "0" ]];then
DropVal="0"
WriteOnly $DropVal $PMConfig/drop_caches.conf
DoDropCacheNow="n"
fi
if [[ "$DoDropCacheNow" == "y" ]];then
# 1 = clear pageCache only.
# 2 = clear dentries and inodes.
# 3 = clear pagecache, dentries, and inodes.
[[ "$DropVal" == "1" ]] && clearType="pageCache"
[[ "$DropVal" == "2" ]] && clearType="dentries and inodes"
[[ "$DropVal" == "3" ]] && clearType="pagecache, dentries, and inodes"
WriteOnly $DropVal /proc/sys/vm/drop_caches
LastDropCache="$(AddTime "$DropValTime")"
SendLogs "clear ram $clearType success, will be triggered again at $(AddTime "$DropValTime" proper)"
fi
if [[ -f /proc/sys/vm/drop_caches ]] && [[ "$DropVal" != "0" ]];then
if [[ -z "$LastDropCache" ]];then
DoDropCacheNow="y"
elif [[ "$LastDropCache" -lt "$(AddTime "0")" ]];then
DoDropCacheNow="y"
else
DoDropCacheNow="n"
fi
[[ "$(echo $LastDropCache | head -c2 )" == "00" ]] && [[ "$(date +"%H")" == "23" ]] && DoDropCacheNow="n"
if [[ "$DropVal" -gt "3" ]];then
DropVal="3"
WriteOnly $DropVal $PMConfig/drop_caches.conf
elif [[ "$DropVal" -lt "0" ]];then
DropVal="0"
WriteOnly $DropVal $PMConfig/drop_caches.conf
DoDropCacheNow="n"
fi
if [[ "$DoDropCacheNow" == "y" ]];then
# 1 = clear pageCache only.
# 2 = clear dentries and inodes.
# 3 = clear pagecache, dentries, and inodes.
[[ "$DropVal" == "1" ]] && clearType="pageCache"
[[ "$DropVal" == "2" ]] && clearType="dentries and inodes"
[[ "$DropVal" == "3" ]] && clearType="pagecache, dentries, and inodes"
WriteOnly $DropVal /proc/sys/vm/drop_caches
LastDropCache="$(AddTime "$DropValTime")"
SendLogs "clear ram $clearType success, will be triggered again at $(AddTime "$DropValTime" proper)"
fi
fi
GetErrorMsg "DoDropCache"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment