21

Top processes sorted by memory usage

Posted in System by matt 3645 days ago

This geeklet displays the top 12 processes sorted by their memory usage. It updates every 30 seconds.

The three columns it shows are given by "command %mem %cpu." You can delete one of those if you don't want it. You can change "head -13" at the end of the command to specify how many processes to show.

Command:

ps -amcwwwxo "command %mem %cpu" | grep -v grep | head -13

Font: Courier
Colour: White
Size: 11

Screenshot

Geeklet files to download

Comments

User Avatar
maelcum 3633 days ago
Why the 'grep -v grep'?

ps -amcwwwxo "command %mem %cpu" | head -13

works nicely for me.
User Avatar
picnictables 2976 days ago
How do I change it to update, instead of every 30 sec to 3 sec or 5 seconds? It's to help my graphic designer wife who constantly complains about her "slow" computer and hates Activity Monitor open. She can just look at the desktop to see what's killing her stuff. Thanks!
User Avatar
chimpysgotswag 2898 days ago
right under where you place the code there's the word Refresh Every and then a box to put the number of seconds you would like it to refresh after. anywhere from 1-2374562349837465 will work. Sadly GeekTool's brain isn't good enough to handle a 0.5 or 0.25. Hope this helped.
User Avatar
chimpysgotswag 2898 days ago
Thanks for this =]
User Avatar
dbuller 2861 days ago
im new to coding and things. would anybody know how to make the process using the most %cpu colored?
User Avatar
miles 2183 days ago
I figured out how to change the command to sort by cpu usage too:

ps -arcwwwxo "command %cpu %mem"

That is, just replace the 'm' by a 'c' in the flag to ps. I switched the output order too.

To make this like a replacement for top (but cleaner to look at), if you have the 'watch' command on your system you can do the following:

watch -n 1 "ps -arcwwwxo \"command %cpu %mem\" | grep -v grep | head -30"

The -n 1 flag tells watch to update every 1 seconds.

Log in to comment or register here.