Skip to content

Instantly share code, notes, and snippets.

@LolWalid
Created March 3, 2020 23:54
Show Gist options
  • Save LolWalid/740f1c74430af7e90eb5dea8f4617693 to your computer and use it in GitHub Desktop.
Save LolWalid/740f1c74430af7e90eb5dea8f4617693 to your computer and use it in GitHub Desktop.
Get 25 process consuming the most RAM
#!/bin/sh
ps -eo rss,pid,user,command | sort -rn | head -25 | awk '{
hr[1024**2]="GB"; hr[1024]="MB";
for (x=1024**3; x>=1024; x/=1024) {
if ($1>=x) { printf ("%-6.2f %s ", $1/x, hr[x]); break }
} } { printf ("%-6s %-10s ", $2, $3) }
{ for ( x=4 ; x<=NF ; x++ ) { printf ("%s ",$x) } print ("\n") }
'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment