Skip to contentSkip to conversation

per-process %CPU

DISCUSSION Albert D. Cahalan 1 participant 1 message Oct 17, 2002 1 message not in the archive

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive
Quoted 9 lines

I want to do following

[root@server13 root]# ps -eo pid,%cpu,%mem,user,args --sort user hC
ps: error: Option C is reserved.
usage: ps -[Unix98 options]
ps [BSD-style options]
ps --[GNU-style long options]
ps --help for a command summary

Quoted 5 lines

but If I replace C by any other OUTPUT MODIFIERS it works. I just want the current %cpu of the process and not the decaying average, so is there an other way to get to my goal?

I tried it on redhat, suse and debian distris ... always the same.

I have bad news for you. The kernel doesn't even maintain the decaying average. Per-process %cpu on Linux is a lie, and always has been -- except with "top", which crudely does a measurement itself.

What you get for %cpu is calculated over the lifetime of the process. Maybe you can find a scheduler hacker to fix this problem. I'll Cc: a few for you.

Guys, this is a POSIX and UNIX requirement. The system is supposed to report per-process %CPU for a "recent" time frame.