aej1973
asked on
log processes with high CPU usage?
Hello,
I have a Ubuntu 12.04 machine. At times I see that there are some processes that are consuming very high CPU capacity. I was wondering if there is a script I can use that runs in the background on my machine that will log all the processes that consume more than 50% of the CPU capacity at any given time and log the output to a text file to review? Thank you.
A
I have a Ubuntu 12.04 machine. At times I see that there are some processes that are consuming very high CPU capacity. I was wondering if there is a script I can use that runs in the background on my machine that will log all the processes that consume more than 50% of the CPU capacity at any given time and log the output to a text file to review? Thank you.
A
ASKER
farzanj, thank you. The thing with sar is that, unlike top, it shows the CPU utilization but does not show which process has taken up the CPU capacity, am I right or am I missing something? Thank you.
Not sure if you want the process id (PID) or the actual command, but to do both, just add in %p (process id) and %a (command) to the ps output options:
ps ahkpcpu -o"%p%C%c%a"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you.
Open in new window
Although you man want to explore tools like sar that do historical record keeping.