What is the unix command for finding the process that is using the least amount of CPU? I know that for finding the most is top, but how about the least? I cannot find the answer anywhere. Also does anyone know any good learning resources? Thank you
-
I'm just curious, why would you want to?Gagan– Gagan2022-01-05 00:28:36 +00:00Commented Jan 5, 2022 at 0:28
-
More explicitly, is this an XY problem?doneal24– doneal242022-01-05 02:18:14 +00:00Commented Jan 5, 2022 at 2:18
Add a comment
|
2 Answers
top -o -%CPU will run top sorting by CPU in reverse.
-
thank you! how would I go about only retrieving that single process to show?rachel– rachel2022-01-05 00:28:27 +00:00Commented Jan 5, 2022 at 0:28
-
1@rachel On a reasonably sized but idle server I have almost 900 processes with 0.0% CPU usage. How do you pick a single process out of that list?doneal24– doneal242022-01-05 01:49:16 +00:00Commented Jan 5, 2022 at 1:49
-
I fear the attempt to "filter out" only the on task with the lowest CPU will yield that very task - e.g. "top -b -n 1 -o %CPU | tail -1" will run top in batch mode, exactly once, sorted by CPU descending and then discards all but the last line. However that last line will probably be the "tail" process itself.Sven Geier– Sven Geier2022-01-06 00:55:40 +00:00Commented Jan 6, 2022 at 0:55
Another option with ps:
ps -ef --sort -%cpu
CPU usage is the 4th column and sorted in decreasing order so that processes with the least CPU usage will be visible near the bottom of the screen, closer to the shell prompt.