Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- # I heavly adapted this script from http://www.vivaolinux.com.br/script/limpa-cache11sh
- # I think the original code is ugly and slow, but has some usable lines.
- # Instructions: Put this script on your path or create a alias for them, so you can use easily.
- echo "Total memory in the system: $(sudo dmidecode -t 19 | grep Range|awk '{print $3 " " $4}')"
- MEM1=$(free|awk '/Mem:/ {print int(100*$3/$2)}')
- echo "RAM memory occupied before cleaning: $MEM1%"
- echo "Cleaning RAM..."
- sync
- echo 3 | sudo tee /proc/sys/vm/drop_caches >/dev/null
- echo "Cleaning swap..."
- sudo swapoff -a
- sudo swapon -a
- MEM2=`free|awk '/Mem:/ {print int(100*$3/$2)}'`
- echo "Memory occupied after cleaning: $MEM2%"
- echo "Economy: $(expr $MEM1 - $MEM2)%"
- exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement