diff --git a/system/etc/ZyC-Core/misc/funclist.sh b/system/etc/ZyC-Core/misc/funclist.sh index c0374a64f3eb3534c01d2bb2fd52ab495b876e78..0d8970af3427aecaf217fa136ff2b0e606eb3448 100644 --- a/system/etc/ZyC-Core/misc/funclist.sh +++ b/system/etc/ZyC-Core/misc/funclist.sh @@ -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"