Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I determine the current CPU utilization from the shell? [closed]

Tags:

linux

How can I determine the current CPU utilization from the shell in Linux?

For example, I get the load average like so:

cat /proc/loadavg 

Outputs:

0.18 0.48 0.46 4/234 30719 
like image 978
Joel Avatar asked Aug 26 '09 07:08

Joel


People also ask

What is the current utilization of the CPU?

CPU utilization refers to a computer's usage of processing resources, or the amount of work handled by a CPU. Actual CPU utilization varies depending on the amount and type of managed computing tasks. Certain tasks require heavy CPU time, while others require less because of non-CPU resource requirements.

Which is the command used to find the CPU usage?

The ps command command displays every process ( -e ) with a user-defined format ( -o pcpu ). First field is pcpu (cpu utilization). It is sorted in reverse order to display top 10 CPU eating process.


1 Answers

Linux does not have any system variables that give the current CPU utilization. Instead, you have to read /proc/stat several times: each column in the cpu(n) lines gives the total CPU time, and you have to take subsequent readings of it to get percentages. See this document to find out what the various columns mean.

like image 164
Martin v. Löwis Avatar answered Oct 20 '22 21:10

Martin v. Löwis