Mac Терминал команды для geektools

1047
flapjacks

Я только что получил Geektools, и я пытаюсь заставить geeklet оболочки отображать команду так top -F -R -o cpuже, как она отображается в терминале. Через Google я нашел эту команду, чтобы показать пакет системной информации:

uptime | awk ''; top -l 1 | awk '/PhysMem/ ' ; top -l 2 | awk '/CPU usage/; NR; 5 '

Это имеет гораздо больше информации о процессоре, чем я хочу / нужно. Я надеюсь заменить информацию о процессоре во второй команде более чистой первой, но я не знаю, как заставить ее отображаться правильно.

1
Я предполагаю, что вы хотите ** точно ** (или как можно ближе) к выводу из `top`? daviewales 11 лет назад 0

1 ответ на вопрос

1
daviewales

Try ps aux. It displays a nice clean output sorted by cpu usage. If you want something even less cluttered, try

ps aux | awk ''; 

To understand this command, just run ps aux, and look at the output. The variable $3 refers to the third column of the output. You can add or remove columns from GeekTool by adding or removing these variables from the command. The large amount of whitespace between the quotation marks just changes the spacing between the columns in the output.

If you want more options, check out the man page by typing man ps. (You can do this for top too. If you're wondering why I didn't suggest a modification using top, it is due to the following issues:

The problem with GeekTool is that it requires output from a command that is static. top can be made to give a static output by using top -l 1, but because it is only making one sample, it can't get the cpu usage. (It needs at least two for that.) You will notice that if you run top -l 1, your cpu usage will be displayed as 0. To rectify that, you can use top -l 2. However this displays the system usage twice, and only the second set of data is correct. This probably wouldn't be helpful for GeekTool. If you still really want to use top, you can try out the following command: top -l 2 -o cpu -R -stats cpu,command. However, it will only display the incorrect data, because it prints that first.