22

Top processes sorted by CPU usage

Posted in System by matt 810 days ago

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

The three columns it shows are given by "command %cpu %mem." 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 -arcwwwxo "command %cpu %mem" | grep -v grep | head -13

Font: Courier
Colour: White
Size: 11

Screenshot

Geeklet files to download

Comments

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

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

works nicely for me.
User Avatar
matt 780 days ago
Ah, oops. While I was playing around with different versions of the script I had grep -v grep to remove grep from the list if it appears. As you say, it's completely unnecessary in the script as it is above.
User Avatar
llorban 720 days ago
How did you get the columns to show in such an orderly fashion? Each line on mine is offset

edit: I see now you used courier font
User Avatar
orbited 498 days ago
Thanks for this! However, I use it to monitor a remote server via SSH and execute:

ssh user@whatever.server 'ps -arcwwwxo "command %cpu %mem" | grep -v grep | head -13'

Doing this also means that the ssh daemon peaks at every update. Is there anyway to make the output strip any line with "sshd" before displying the results?
User Avatar
matt 167 days ago
Try adding `| grep -v sshd |` in the middle
User Avatar
orbited 498 days ago
Never mind the above - Google is my friend! :)

ssh user@whatever.server 'ps -arcwwwxo "command %cpu %mem" | grep -v grep | grep -v "^sshd" | head -13'
User Avatar
ryjacs 205 days ago
Is there a way to change the font and still have the columns aligned?
User Avatar
matt 167 days ago
Any "fixed width" font will be fine. That restricts you a bit, but there are a fair few. Menlo is one of my favourites.

Log in to comment or register here.