Skip to content

How to find top 15 Processes by Memory Usage with top in Batch Mode?

1 min read

To display the top 15 processes sorted by memory use in descending order, do:

# top -b -o +%MEM | head -n 22

 

As opposed to the previous tip, here you have to use +%MEM (note the plus sign) to sort the output in descending order.

 

From the command above, the option:

  • -b : runs top in batch mode
  • -o : used to specify fields for sorting processes
  • head utility displays the first few lines of a file and
  • the -n option is used to specify the number of lines to be displayed.

 

Redirect or Save ‘top’ Output to File in Linux

 

Additionally, using top in batch mode allows you to redirect the output to a file for later inspection:

# top -b -o +%MEM | head -n 22 > topreport.txt

 

Related services

KVM VPS hosting

NVMe SSD and full root access, with Free Basic Managed Support.

Unmanaged dedicated servers

full root access and free IPMI KVM, with Free Basic Managed Support.

Linux server management

hardening, patching, monitoring and automation for Ubuntu, Debian, RHEL and AlmaLinux.

Was this answer helpful?

Still stuck? Open a ticket