Skip to content

Instantly share code, notes, and snippets.

@spot62
Last active November 21, 2016 08:47
Show Gist options
  • Save spot62/4610c60175082c90f3c7fa5b5a816e69 to your computer and use it in GitHub Desktop.
Save spot62/4610c60175082c90f3c7fa5b5a816e69 to your computer and use it in GitHub Desktop.
Sort proccess by memory used
#!/bin/bash
#sort
ps -eo size,pid,user,command | awk '{ hr=$1/1024 ; printf("%13.6f Mb ",hr) } { for ( x=4 ; x<=NF ; x++ ) { printf("%s ",$x) } print "" }' | sort
# memory statistics
cat /proc/meminfo
# drop cache (but not for VPS)
sync
echo 1 > /proc/sys/vm/drop_caches
echo 2 > /proc/sys/vm/drop_caches
echo 3 > /proc/sys/vm/drop_caches
# clear swap
swapoff -a
swapon -a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment