Click to See Complete Forum and Search --> : top and ps mis-reporting process running time


etek
08-18-2004, 03:48 PM
Hello,

I am writing a script that will kill out-of-control processes (usually stick vim, tar, and apache processes). I've ran into a strange problem. I am using 'ps' to get the process statistics. If a process is running over a specified time (10-30 minutes), it will be killed. This is run on a cron to run every 10 minutes, so theoretically, no processes (in the list) should be running longer than 30 minutes.

If I run top and look at the times on the processes I'll see processes that have been running longer than 30 minutes ("34:10" for example). However, if I do a `ps aux | grep (PID)` then the time there only shows something like "0:18"? Am I missing something here? Is there a reason top reports it's been running for 34 minutes 10 seconds and ps reports it's been running for 18 seconds? Server is on a SMP kernel 2.4.20.

Thanks in advance

--
Linux Hosting Forum - http://www.linuxhostingforum.com

etek
08-19-2004, 09:38 AM
Figured it out:

ps Saux

The 'S' is the cumalitive time (parent+children).

--
Linux Hosting Forum - http://www.linuxhostingforum.com

hard candy
08-19-2004, 09:43 AM
Thanks for replying to your own post, because now I learned something. :D

Icarus
08-19-2004, 10:59 AM
Thanks, me too :D

I've never dug too much into process times since at work I'm use to seeing them run for more then 8 hours (accounting loves their reports)

I think it's time for me to read the ps man page some more :p