Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I use Ubuntu 12.04.1 Linux. I see a difference between %CPU and C output format of ps command for a process. It is not clearly noted in the ps man page.

Man pages says:

  CODE       HEADER  DESCRIPTION
  %cpu       %CPU    cpu utilization of the process in "##.#" format. Currently, 
                     it is the CPU time used divided by the time the 
                     process has been running (cputime/realtime ratio),
                     expressed as a percentage. It will not add up to 100%
                     unless you are lucky. (alias pcpu).
  c          C       processor utilization. Currently, this is the integer                  
                     value of the percent usage over the lifetime of the
                     process. (see %cpu).

So basically it should be the same, but it is not:

$ ps aux | head -1
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
$ ps aux | grep 32473
user     32473  151 38.4 18338028 6305416 ?    Sl   Feb21 28289:48 ZServer -server -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=./log 


$ ps -ef | head -1
UID        PID  PPID  C STIME TTY          TIME CMD
$ ps -ef | grep 32473
user     32473 32472 99 Feb21 ?        19-15:29:50 ZServer -server -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=./log 

The top shows 2% CPU utilization in the same time. I know the 'top' shows the current CPU utilization while ps shows CPU utilization over the lifetime of the process.

I guess the lifetime definition is somewhat different for these two format options.

share|improve this question
1  
Maybe 99 is the maximum value that ps -ef could display ? –  digital_infinity Mar 6 at 12:48

1 Answer 1

You can check out this - http://unix.stackexchange.com/a/28724/55815

I think that answers your question

share|improve this answer
    
Thanks for the suggestion but this does not actually answers my question - what is the difference. The answer says a lot about CPU utilization over the lifetime of the process. This is what I already know. –  digital_infinity Mar 11 at 10:46

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.