Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I get a CPU% for a PID?

Status
Not open for further replies.

chaucer

IS-IT--Management
Jun 12, 2003
6
0
0
GB
I'm trying to create a script that will match a pid up with it's CPU% usage. I do not know how the heck I get this information. top and glance are really screwy. They are all on one line, and very hard to deal with (delimiters). Is there a command or some other utility that will give me this information? This seems much more difficult than it ought to be!!!

 
Chaucer,

Try the following UNIX command:
ps -efo pid,pcpu,args

this will display the Process ID, % CPU used and process name and arguments for all running processes. You could simply pipe the output to grep to find only the PID which interests you.
 
Hi.

you can use the comand:

ps -efo pcpu,comm | grep process
 
Login as root.
Use this command:

ps -ef | sort -k4


This will give you a list of processes with the CPS usages in descending order. The process using the most processor time will be listed at the bottom. The percentage will be the 4th field in the line.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top