Wednesday, April 13, 2022

[SOLVED] Limit top command to only display top X processes on command line

Issue

I'm not sure why there is not an option in the top command that does this, as it seems to be a natural request.

If I pipe the output of top to head, then the list doesn't update and I get static output once. I could then bring the watch command into action, which would do the job. But, is there a simpler solution?


Solution

> top

then, press n to set maximum tasks displayed.

When operating top, one of the most important key is help (h or ?) to see the available options (n is given in help).

UPDATE (after the the comment):

PERSONAL Configuration File might help for the batch mode. Run top then set the maximum tasks displayed with n and use the W interactive command to create or update the configuration file. top will be ran according to the configuration file next time.



Answered By - Alper
Answer Checked By - Dawn Plyler (WPSolving Volunteer)