- 
      
- 
        Save alexandre2602/d4552bd33bbeea0fc4573c74e2c0b8de to your computer and use it in GitHub Desktop. 
Revisions
- 
        rmsaitam created this gist Nov 14, 2018 .There are no files selected for viewingThis 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,47 @@ #!/bin/sh #!/bin/sh # https://blog.remontti.com.br/92 PATH="/bin:/usr/bin:/usr/local/bin" # Porcentagem maxima (mude se vc achar q deve) eu deixo em 85% percent=85 # Total da memoria: ramtotal=`grep -F "MemTotal:" < /proc/meminfo | awk '{print $2}'` # Memoria livre: ramlivre=`grep -F "MemFree:" < /proc/meminfo | awk '{print $2}'` # RAM utilizada pelo sistema: ramusada=`expr $ramtotal - $ramlivre` # Porcentagem de RAM utilizada pelo sistema: putil=`expr $ramusada \* 100 / $ramtotal` echo =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= date echo echo "Mem. utilizada: $putil %"; if [ $putil -gt $percent ] then date=`date` echo $date >> /var/log/memoria.log echo "Mem. utilizada: $putil %" >> /var/log/memoria.log echo "Memoria acima de $percent %, cache foi limpado!"; sync # 'Dropando' cache: echo 3 > /proc/sys/vm/drop_caches # Caso nao esteja utilizanod debian, descomente a linha abaixo # sysctl -w vm.drop_caches=3 echo free -m echo echo =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- else echo "Cache nao foi limpado!"; echo =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- unset percent ramtotal ramlivre ramusada putil exit $? fi