Monitoring the server load and CPU usage one of the main task of the system administrator. Finding the Top CPU Consuming processes which causes the heavy load on the Linux system is important. So that You can easily solve the issues in the Linux System. Mostly automated scripts are used to monitor the Memory utilization and CPU Consumption Resources. Here I’ll share you the best ways to find High CPU Consuming Processes in the Linux.
1. Using PS Command to find Top CPU Usage processes
In the terminal enter the following Linux Command to get the list of the processes Ordered by RAM and CPU
ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem | head
Example output:
PID PPID CMD %MEM %CPU 2551 1153 /usr/lib/chromium-browser/c 12.0 7.8 3231 2769 /usr/lib/chromium-browser/c 8.6 2.5 2850 2551 /usr/lib/chromium-browser/c 7.5 4.7 20958 1153 /usr/lib/firefox/firefox 5.7 1.5 21093 20958 /usr/lib/firefox/firefox -c 4.7 1.4 21019 20958 /usr/lib/firefox/firefox -c 4.3 8.5 3763 2769 /usr/lib/chromium-browser/c 2.7 0.1 3663 2769 /usr/lib/chromium-browser/c 2.7 0.6 18221 2769 /usr/lib/chromium-browser/c 2.6 1.7
The PS command with following extra options and format displays the top 10 CPU consuming processes in Linux. If you remove the PIPE | symbol and HEAD in the above command, that will list all processes ordered by CPU Usage or RAM Utilization.
Do you Know : How to Securely Copy Files using SCP Examples in Linux
2. Find Real-time Continuous CPU Consuming Processes
If you want to monitor the Real-time Continuous High CPU Consuming Processes, the you have use Watch Command to get the desired output. The Watch command will update the top 10 CPU Consuming processes every 2 second.
watch "ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%cpu | head"
Sample OutPut:
Every 2.0s: ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%cpu | head Sun Jan 15 05:40:32 2017 PID PPID CMD %MEM %CPU 2551 1153 /usr/lib/chromium-browser/c 12.0 7.8 3231 2769 /usr/lib/chromium-browser/c 8.6 2.5 2850 2551 /usr/lib/chromium-browser/c 7.5 4.7 20958 1153 /usr/lib/firefox/firefox 5.7 1.5 21093 20958 /usr/lib/firefox/firefox -c 4.7 1.4 21019 20958 /usr/lib/firefox/firefox -c 4.3 8.5 3763 2769 /usr/lib/chromium-browser/c 2.7 0.1 3663 2769 /usr/lib/chromium-browser/c 2.7 0.6 18221 2769 /usr/lib/chromium-browser/c 2.6 1.7
3 . Find the Top CPU Consumption using htop
Most of the basic Linux users have already knew the top command that will show you the list of top processes running in the system. This ‘htop’ command will show you the Top command in the in best visualisation.
Mostly, By default the htop program not installed in Top Linux Distros like Ubuntu. Just install htop using apt command.
sudo apt get install htop
The above command will install htop tool. Just enter htop in the terminal to get complete process list currently running on your Linux system.
4. Use the Top Command to get Top CPU Processes
Like I said before in the previous way, just entering the top in the Terminal will get you the top list of CPU Usage processes. Top is the Realtime system Montitor using the you can list the processes based on memory Utilisation and CPU Utilisation.
5. Use the atop Command
Like htop, another one command is called ‘atop’. Atop is a ASCII full-screen performance monitor which can log and report the activity of all server processes.
Install atop on RHEL/CentOS/Fedora Linux
First install and enable EPEL (Extra Packages for Enterprise Linux) repo. See: RedHat solution #308983.
yum install atop
Install atop on Debian/Ubuntu Linux
apt-get install atop
Once installed on any distro, you can launch it similar to top using:
atop
Use man atop to get more about this complete server processes monitor.
The above ways will really helpful to get the top CPU Consuming processing and RAM usage processes.