Tuesday, April 23, 2024
5
rated 0 times [  5] [ 0]  / answers: 1 / hits: 2893  / 1 Year ago, wed, may 17, 2023, 6:41:22

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?


More From » command-line

 Answers
7

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


[#23333] Wednesday, May 17, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
oraoming

Total Points: 354
Total Questions: 105
Total Answers: 124

Location: Iraq
Member since Sat, Apr 3, 2021
3 Years ago
oraoming questions
Fri, Aug 20, 21, 10:08, 3 Years ago
Mon, May 24, 21, 21:56, 3 Years ago
Mon, Dec 12, 22, 23:21, 1 Year ago
Mon, Sep 12, 22, 11:38, 2 Years ago
;