Apple changed the usage of the “top” command in Terminal, so my output of processes ordered by CPU usage got broken in GeekTool.

After poking around in Terminal, I found the right recipe, kind of:

top -F -R -l2 -o cpu | grep -v '0.0' | tail -n +19 | grep -v 'PID' | cut -c 1-29

At times it will output some additional information at the top, but this is good enough for me.

Update:

I’ve found a better solution. It is:

top -F -R -l2 -o cpu | cut -c 1-29 | grep -v '0.0' | tail -n +19 | grep -v 'PID'

If you want to output processes sorted by memory usage, you can use:

top -F -l1 -o vsize | cut -c 1-24,89-96  | tail -n +12 | head -n 10

The last number 10 indicated number of lines in the list.

processes-in-geektool

Posted Thursday, November 12th, 2009 at 2:09 pm
Filed Under Category: OS X
You can leave a response, or trackback from your own site.

4

Responses to “Make “top” command work with GeekTool on Snow Leopard”

Papalazarou

This is excellent, I’ve been looking for a solution also.

How have you formatted your text? Mine outputs with single spaces between each field, whereas yours are aligned.

admin

Are you using a mono-spaced font like Courier or Monaco?

tom holland

I’ve been looking for a while for a nice one line command to display top command info sorted by %cpu to use in Geektool under Lion. These seemed to be it since it works in Terminal very nicely. However, it fails in Geektool (v3.0.3). Have you got a version that works in Lion?

Thanks!

admin

Sorry, but I’m not using that particular script anymore.

Leave a Reply