Sponsored Content
Top Forums UNIX for Advanced & Expert Users [Linux] How much time a process waited for CPU? Post 302711623 by sant on Sunday 7th of October 2012 10:25:15 AM
Old 10-07-2012
[Linux] How much time a process waited for CPU?

Hi,

Is it possible in Linux to find out how much time a process waited for CPU?
In Solaris we can see it in prstat.

Thanks
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

how to get persistant cpu utilization values per process per cpu in linux (! top,ps)

hi, i want to know cpu utilizatiion per process per cpu..for single processor also if multicore in linux ..to use these values in shell script to kill processes exceeding cpu utilization.ps (pcpu) command does not give exact values..top does not give persistant values..psstat,vmstat..does njot... (3 Replies)
Discussion started by: pankajd
3 Replies

2. UNIX for Advanced & Expert Users

how to know which process consume CPU time more

Hi, I have problem like everyday i have to check which process consuming more cpu time. I have done it manually using top command.. Is there any script which will tell the exact process name which will consuming more time. I am using hpux. (1 Reply)
Discussion started by: rajesh08
1 Replies

3. Shell Programming and Scripting

Why CPU time is longer than Elasped time?

I thought a program's elapsed time, some program language call it real time, should be the time of a program from start to finish. And it should be equal or longer than CPU time. This is true for the most of the cases. However, I do see some of my programs CPU time is longer than Elapsed time. ... (1 Reply)
Discussion started by: visio2000
1 Replies

4. UNIX Desktop Questions & Answers

Killing a process if it is not using any cpu time

Hi i am a newbie thanks in advance i have a process which keeps on running but doesn't use any CPU time and doesn't do the functionality which it is suppose to do . If i kill the process and start the process again then the process kicks in and starts using CPU time and continues to do its... (3 Replies)
Discussion started by: nick1982
3 Replies

5. Solaris

process CPU time

We are using JAVA program and strange thing is it takes 100% CPU when not in use. The program function is to stream a file on output port (one direction). It checks one directory and when there is a file in it, starts. While it is streaming the CPU usage is normal, about 20%. But, if... (9 Replies)
Discussion started by: orange47
9 Replies

6. Shell Programming and Scripting

what would a script include to find CPU's %system time high and user time high?

Hi , I am trying to :wall: my head while scripting ..I am really new to this stuff , never did it before :( . how to find cpu's system high time and user time high in a script?? thanks , help would be appreciated ! :) (9 Replies)
Discussion started by: sushwey
9 Replies

7. UNIX Desktop Questions & Answers

Automatically killing a process if it doesn't use any CPU time

Hi, I'm new to Linux. I have a windows server that run many processes on it. In some cases the processes doesn't exit properly or just stop working and the process needs to be killed. I was wondering how i can automatically (couple of times a day) check which process doesn't use any CPU... (3 Replies)
Discussion started by: ramikom
3 Replies

8. Emergency UNIX and Linux Support

CPU and memory utilization of a process, by process name

Can someone please help me with a script that will help in identifying the CPU & memory usage by a process name, rather than a process id.This is to primarily analyze the consumption of resources, for performance tweaking. G (4 Replies)
Discussion started by: ggayathri
4 Replies

9. Shell Programming and Scripting

Shell script for logging cpu and memory usage of a Linux process

I am looking for a way to log and graphically display cpu and RAM usage of linux processes over time. Since I couldn't find a simple tool to so (I tried zabbix and munin but installation failed) I started writing a shell script to do so The script file parses the output of top command through... (2 Replies)
Discussion started by: andy_dufresne
2 Replies

10. Shell Programming and Scripting

Do we have generic solution get process start time in AIX & Linux

I wish to get the process start time on AiX and Linux using the same command / script. I'm able to get the process start time in Linux using the below command: cat /proc/<pid>/stat | grep Modify The same does not work for AiX 6.1 systems. Can you please let me know the command to get... (4 Replies)
Discussion started by: mohtashims
4 Replies
CLOCK_GETCPUCLOCKID(3)					     Linux Programmer's Manual					    CLOCK_GETCPUCLOCKID(3)

NAME
clock_getcpuclockid - obtain ID of a process CPU-time clock SYNOPSIS
#include <time.h> int clock_getcpuclockid(pid_t pid, clockid_t *clock_id); Link with -lrt (only for glibc versions before 2.17). Feature Test Macro Requirements for glibc (see feature_test_macros(7)): clock_getcpuclockid(): _POSIX_C_SOURCE >= 200112L DESCRIPTION
The clock_getcpuclockid() function obtains the ID of the CPU-time clock of the process whose ID is pid, and returns it in the location pointed to by clock_id. If pid is zero, then the clock ID of the CPU-time clock of the calling process is returned. RETURN VALUE
On success, clock_getcpuclockid() returns 0; on error, it returns one of the positive error numbers listed in ERRORS. ERRORS
ENOSYS The kernel does not support obtaining the per-process CPU-time clock of another process, and pid does not specify the calling process. EPERM The caller does not have permission to access the CPU-time clock of the process specified by pid. (Specified in POSIX.1-2001; does not occur on Linux unless the kernel does not support obtaining the per-process CPU-time clock of another process.) ESRCH There is no process with the ID pid. VERSIONS
The clock_getcpuclockid() function is available in glibc since version 2.2. ATTRIBUTES
For an explanation of the terms used in this section, see attributes(7). +----------------------+---------------+---------+ |Interface | Attribute | Value | +----------------------+---------------+---------+ |clock_getcpuclockid() | Thread safety | MT-Safe | +----------------------+---------------+---------+ CONFORMING TO
POSIX.1-2001, POSIX.1-2008. NOTES
Calling clock_gettime(2) with the clock ID obtained by a call to clock_getcpuclockid() with a pid of 0, is the same as using the clock ID CLOCK_PROCESS_CPUTIME_ID. EXAMPLE
The example program below obtains the CPU-time clock ID of the process whose ID is given on the command line, and then uses clock_get- time(2) to obtain the time on that clock. An example run is the following: $ ./a.out 1 # Show CPU clock of init process CPU-time clock for PID 1 is 2.213466748 seconds Program source #define _XOPEN_SOURCE 600 #include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <time.h> int main(int argc, char *argv[]) { clockid_t clockid; struct timespec ts; if (argc != 2) { fprintf(stderr, "%s <process-ID> ", argv[0]); exit(EXIT_FAILURE); } if (clock_getcpuclockid(atoi(argv[1]), &clockid) != 0) { perror("clock_getcpuclockid"); exit(EXIT_FAILURE); } if (clock_gettime(clockid, &ts) == -1) { perror("clock_gettime"); exit(EXIT_FAILURE); } printf("CPU-time clock for PID %s is %ld.%09ld seconds ", argv[1], (long) ts.tv_sec, (long) ts.tv_nsec); exit(EXIT_SUCCESS); } SEE ALSO
clock_getres(2), timer_create(2), pthread_getcpuclockid(3), time(7) COLOPHON
This page is part of release 4.15 of the Linux man-pages project. A description of the project, information about reporting bugs, and the latest version of this page, can be found at https://www.kernel.org/doc/man-pages/. Linux 2017-09-15 CLOCK_GETCPUCLOCKID(3)
All times are GMT -4. The time now is 09:55 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy