Thanks for the info.<br><br><div><span class="gmail_quote">On 6/16/06, <b class="gmail_sendername">Alan McKinnon</b> <<a href="mailto:alan@linuxholdings.co.za">alan@linuxholdings.co.za</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On Thursday 15 June 2006 10:01, neil al wrote:<br>> Hi,<br>><br>> May I know what is the difference between the 'nice ps -eo<br>> pid,user,time,%cup%' and 'top' command. For example when i run a<br>> tomcat servlet container the nice ps -eo pid,user,time,%cup%
<br>> command will print java process has a very large cpu usage and on<br>> the other hand, when try the top command the java process has<br>> little or no cpu usage. Both commands have different output values.<br>
<br>ps and top are not displaying the same thing, even though the use the<br>same name for them.<br><br>From the ps man page:<br>CODE  HEADER  DESCRIPTION<br><br>%cpu  %CPU    cpu utilization of the process in "##.#" format.
<br>              Currently, it is the CPU time used divided by the time<br>              the process has been running (cputime/realtime ratio),<br>              expressed as a percentage. It will not add up to 100%<br>              unless you are lucky. (alias pcpu).
<br><br>From the top man page:<br>k: %CPU  --  CPU usage<br>   The task's share of the elapsed CPU time since the last screen<br>   update, expressed as a percentage of total CPU time.  In a true SMP<br>   environment, if 'Irix mode' is Off, top will operate in 'Solaris
<br>   mode' where a task's cpu usage will be divided by  the  total<br>   number  of  CPUs.   You toggle 'Irix/Solaris' modes with the 'I'<br>   interactive command.<br><br>So ps calculates cpu usage by using the entire time the process has
<br>been running giving a broad average over time. top considers only the<br>last second (by default), which can be very different from the ps<br>value under heavy load.<br><br>Analogy: consider a Formula 1 car. It does 200mph down the main
<br>straight - this is top. It also covers the 200 mile race in 1h30min,<br>and average of 133 mph - this is ps<br><br>--<br>If only me, you and dead people understand hex,<br>how many people understand hex?<br><br>Alan McKinnon
<br>alan at linuxholdings dot co dot za<br>+27 82, double three seven, one nine three five<br><br>--<br>ubuntu-users mailing list<br><a href="mailto:ubuntu-users@lists.ubuntu.com">ubuntu-users@lists.ubuntu.com</a><br><a href="https://lists.ubuntu.com/mailman/listinfo/ubuntu-users">
https://lists.ubuntu.com/mailman/listinfo/ubuntu-users</a><br></blockquote></div><br>