Skip to content

Instantly share code, notes, and snippets.

@hudsantos
Created December 2, 2015 10:46
Show Gist options
  • Save hudsantos/7fec7d9c34cc472b7f98 to your computer and use it in GitHub Desktop.
Save hudsantos/7fec7d9c34cc472b7f98 to your computer and use it in GitHub Desktop.
Simple ShellScript to free your memory and cache on Linux systems
#!/bin/sh
before=`free -m| grep -A1 free|tail -1 | awk '{print $4}'`
echo "free memory before: $before Mbytes"
echo "cleaning mem!"
sync; echo 3 > /proc/sys/vm/drop_caches
after=`free -m| grep -A1 free|tail -1 | awk '{print $4}'`
gift=`expr $after - $before`
echo "free memory after: $after Mbytes (gift of $gift Mbytes)"
echo "done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment