3

I want top command to show processes that are greater than PID xxx is there a switch that can do that? also can I sort the output based on the PID number instead of the CPU usage?

2
  • You can press h to see the various options your top supports.
    – muru
    Sep 5, 2014 at 16:02
  • Hinklo, my comment below may have passed unnoticed - could you please add the output of top -v and dpkg -S $(which top) to your post? I suspect you may be using some unusual implementation. The normal way to solve your problem should work, as can be seen in this video: youtube.com/watch?v=tE1le-9lALc. Sep 12, 2014 at 19:14

3 Answers 3

5
+50

By default top runs every 3s.

You can monitor processes greater than PID XXX by using the watch command and top in batch mode (with -b, for 1 iteration with -n 1 and sorted by PID with -o PID):

watch -n 3 "top -o PID -b -n 1 | perl -ne '/^\s+(\d+)\s+/; print if (not \$1 or \$1 > 5000)'"

Where for example 5000 is my threshold:

enter image description here

Tested on 14.04

0
4

You can run top -o PID to sort by PID (or hit the < key several times while top is running to move the sort column to the right, until it's sorting by PID).

You can filter PIDs interactively while top is running by hitting the o key and typing PID>1000 or whatever minimum value you want, followed by enter.

8
  • 2
    It didn't work, any other way?
    – Hinklo
    Sep 8, 2014 at 12:31
  • @Hinklo This works, and this is the way you would do it. Instead of looking for "some other way", I'd investigate why it doesn't work for you. What exactly happened (i.e, what does "it didn't work" mean)? Are you referring to the sorting, or the filtering? or did neither work? You may have done something wrong. Did you try the PID>1000 filter as suggested by Stephen for a start? You can also see a list of active filters by hitting Ctrl+o. Do you see the PID>1000 one? Pay attention to upper-/lowercase: pid>1000 will not work. Sep 9, 2014 at 8:29
  • This is what I get when I press the letter "o" , small letter
    – Hinklo
    Sep 9, 2014 at 10:32
  • youtube.com/watch?v=jAbiIwr-7wU
    – Hinklo
    Sep 9, 2014 at 10:33
  • 3
    I can confirm the filter does not work on Ubuntu 14.04. And no, it is not clear why, it functions with other fields. Sep 9, 2014 at 18:29
2

An alternative would be to try out htop

Some examples are here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.