1 |
On 2012-03-02 3:50 PM, Paul Hartman <paul.hartman+gentoo@×××××.com> wrote: |
2 |
> On Fri, Mar 2, 2012 at 2:39 PM, Tanstaafl<tanstaafl@×××××××××××.org> wrote: |
3 |
>> On 2012-03-02 2:33 PM, Paul Hartman<paul.hartman+gentoo@×××××.com> wrote: |
4 |
>>> |
5 |
>>> And you can use the --sort options for ps to sort by cpu or anything |
6 |
>>> you like (see the manpage) |
7 |
>> |
8 |
>> |
9 |
>> Even better, thanks Paul... |
10 |
>> |
11 |
>> watch -n1 "ps aux --sort=-%cpu | gawk '{ if ( \$3> 1.0 ) { print } }'" |
12 |
>> |
13 |
>> does exactly what I want... |
14 |
>> |
15 |
>> Hmmm... is there an easy way to include the column headers? |
16 |
> |
17 |
> To build on Grant's suggestion: |
18 |
> ps aux --sort %cpu | gawk 'NR==1; $3> 0' |
19 |
|
20 |
Hmmm.. ok, this works beautifully, thanks! |
21 |
|
22 |
But when I tried to incorporate it into the watch command like the other |
23 |
one: |
24 |
|
25 |
Original: |
26 |
watch -n1 "ps aux --sort=-%cpu | gawk '{ if ( \$3 > 1.0 ) { print } }'" |
27 |
|
28 |
Attempt at incorporating your command into this: |
29 |
watch -n1 "ps aux --sort=-%cpu | gawk 'NR==1; $3 > 0'" |
30 |
|
31 |
it gives me a syntax error: |
32 |
|
33 |
Every 1.0s: ps aux --sort=-%cpu | gawk 'NR==1; > 0' |
34 |
|
35 |
Fri Mar 2 |
36 |
16:19:01 2012 |
37 |
|
38 |
gawk: NR==1; > 0 |
39 |
gawk: ^ syntax error |
40 |
|
41 |
Any ideas on how to get this working in the watch version |
42 |
|
43 |
Thanks Paul, this will be very useful to me... |