LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   find out how much time an already running process is spending in user and kernel spac (https://www.linuxquestions.org/questions/linux-newbie-8/find-out-how-much-time-an-already-running-process-is-spending-in-user-and-kernel-spac-885277/)

Valentin 06-08-2011 04:30 PM

find out how much time an already running process is spending in user and kernel spac
 
Good evening,

I am currently struggling with one of my tasks.
I was asked to find a way how to determine how much time an _already running_ process is spending in user and kernel space.

E.G. <some tool> <pid>
[Control] + [c]

<pid> spent 12.1 seconds in user and 1.52 seconds in kernel space.


Does something like this exist? Basically I guess I am looking for something similar to time, except that the process is already running.

So..
a) Is there a tool which fulfills this task?
b) Is there a way to write your own software which does the job? Is it even possible to code something I am looking for?

I recently found strace -c -p <pid>, but well, this is not exactly what I was looking for.

Any reply is highly appreciated.

Best regards,
Valentin

roygbiiv 06-08-2011 04:42 PM

I'm not sure exactly what you want, but check out the 'time' command which takes programs as argument and displays elapsed time.

Valentin 06-08-2011 04:56 PM

I am looking for a possibility to use something like "time" for processes which are already running.

Like using "time" on a running slapd.

time only offers the possibility to track the stats for new processes, but not for running ones.

Valentin 07-05-2011 02:58 PM

Any help would be highly appreciated. I need to find out how much time a process spends in user/kernel space, but the command was not startet with "time".


All times are GMT -5. The time now is 07:19 PM.