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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Weird issue with ps aux runtimes?

Status
Not open for further replies.

youradds

Programmer
Jun 27, 2001
817
0
0
GB
Hi,

I've got a bit of a weird issue here. I'm running a script (which takes a while to run), but it always gives me the wrong runtime for the process. See this:

Code:
chambr22 28223 52.8  0.5  53372 45744 pts/0    R+   10:34  [B]28:44[/B] perl nph-build-custom.cgi

..yet the time at the moment, is:

Code:
Sat Aug 17 11:31:43 CEST 2013

..so its actually been going about an hour. This tallys up with what I was saying in my email conversations with someone (telling them that I was about to restart the build)

Its weird - as it has the time (10:34) correct... so I would have assumed it got the runtime based on the current time - start time... no?

Cheers

Andy
 
I'm not sure what you're asking.

The start time reported is recorded when the process starts. It's not calculated. CPU time the process uses is broken down into USER and SYSTEM time. Elapsed ("real") time is calculated from start time to current time.

 
If you're talking about that "28:44", that's the CPU time that the process has accrued since it started, not elapsed time. If you look at the third column, "%CPU", it shows 52.8%. That means if the process is getting around 50% of a CPU for one hour elapsed ("real") time, then after one hour has gone by, 28 minutes and 44 seconds of CPU time sounds about right.

 
If you can run your command like this, it will show you how the time breaks down...

Code:
time perl nph-build-custom.cgi

 
Hi,

Ah, I never knew that. I always assumed that it was just the time elapsed since the start of the process. Thanks for clearing that up :)

The "time" feature... thats to be used when running something? ie. I would just add "time" in front of my command?

Cheers

Andy
 
Yes, "[tt]time[/tt]" is a command that doesn't affect the command after it on the command line. It just reports the amount of time the process took ("[tt]man time[/tt]").

Code:
$ time ( find . -name '*.c' -ls > /dev/null 2>&1 )

real    0m2.94s
user    0m0.08s
sys     0m0.55s

The example took 2.94 seconds of real time. That's the elapsed time on the clock on the wall. It took a total of 0.63 seconds of CPU time, which was 0.08 seconds user CPU and 0.55 seconds system CPU.

This is a good way to see if your process is CPU bound or IO bound if you have one that's taking longer than expected.

 
Ah nice - I will have to give that a go :) I've typed "time" in by accident (when meaning to do "date") in command prompt, but never thought to try it in front of a command I'm running :)

Thanks!

Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top