4 amazing ways to find high CPU load in Linux.

Most of the sysadmin’s time is spent looking for the cause of the load, for example, on the system. Search for processes that are consuming resources. This article will help you quickly find high-load CPU processes in Linux.

1. Discovering main processor processes in Linux using the ps command.

There is one line code available with the ps command to help you find high CPU CPU processes in Linux.

Command:

 ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%cpu | head

Output example:

[[email protected] ~]# ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%cpu | head
  PID  PPID CMD                         %MEM %CPU
23236 20520 dd if=/dev/zero of=/dev/nul  0.0 85.3
19509     1 /usr/bin/Xvnc :1 -desktop r  0.7  0.2
19559 19514 nautilus                     0.3  0.2
19668     1 /usr/lib64/firefox-3.6/fire  2.2  0.2
    1     0 /sbin/init                   0.0  0.0
    2     0 [kthreadd]                   0.0  0.0
    3     2 [migration/0]                0.0  0.0
    4     2 [ksoftirqd/0]                0.0  0.0
    5     2 [migration/0]                0.0  0.0
[[email protected] ~]#

2. Constant monitoring of highly loaded processor processes in Linux.

Let’s say you don’t want any example of the command output, instead you want to monitor the output continuously. Yes, you can do it with the command watchas shown below:

Command:

[[email protected] ~]# watch "ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%cpu | head"

Output example:

Every 2.0s: ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%cpu | head                                                                                   Tue Apr 20 13:35:32 2017
 
  PID  PPID CMD                         %MEM %CPU
22361 20520 dd if=/dev/zero of=/dev/nul  0.0 85.3
18976     1 /usr/bin/Xvnc :1 -desktop r  0.7  0.2
18989 19514 nautilus                     0.3  0.2
19234     1 /usr/lib64/firefox-3.6/fire  2.2  0.1
    1     0 /sbin/init                   0.0  0.0
    2     0 [kthreadd]                   0.0  0.0
    3     2 [migration/0]                0.0  0.0
    4     2 [ksoftirqd/0]                0.0  0.0
    5     2 [migration/0]                0.0  0.0

3. Highly loaded CPU processes in Linux using the top command.

The same ps command output can also be achieved using the Linux native top command to find active processor processes in Linux.

Command:

[[email protected] ~]# top -b -n 1 | head -n 12  | tail -n 6

Output example:

[[email protected] ~]# top -b -n 1 | head -n 12  | tail -n 6
  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
22361 root      20   0  102m  345  568 R 100.0  0.0  08:34.12 dd
22379 root      20   0 14563 1221 848  R  2.0  0.0   0:00.01  top
    1 root      20   0 14352 1435 1324 S  0.0  0.0   0:01.34  init
    2 root      20   0     0    0    0 S  0.0  0.0   0:00.01  kthreadd
    3 root      RT   0     0    0    0 S  0.0  0.0   0:05.08  migration/0
[[email protected] ~]#

4. Find the high loaded CPU processes in Linux using the htop command.

Similar to the top utility, htop is a Linux command that will help you find high-load CPU processes in Linux. To find them, use the “htop” command.

Command:

[[email protected] ~]# htop

After you have entered the htop command, Continuous Move will open a window at the top, as shown below:

Now, to understand the processes for using the CPU, simply press the “F6” button, and then select the processor and press the ENTER key. You will now see the processes sorted by CPU usage, as shown below:

top-cpu-consuming-processes-in-Linux1

Sidebar