Sponsored Content
Top Forums Shell Programming and Scripting Command to check the CPU usage for particular user Post 302470050 by bakunin on Tuesday 9th of November 2010 04:49:23 AM
Old 11-09-2010
Have a look at the man page of "ps", especially the "-o" option and its various arguments. For instance, the following will show the CPU%, the PID and the CMD columns of each process, sorted by CPU consumption:

Code:
ps -Alo pcpu,pid,args | sort -rn

You might probably want to modify the command according to your needs and what you find in the man page.

I hope this helps.

bakunin
 

10 More Discussions You Might Find Interesting

1. HP-UX

How to determine cpu&memory percentage usage per user

Using HP-UX v11 Need to monitor cpu and memory usage, total for system and separately for each user in command-line mode. Found out next ways to monitor total cpu usage under hp-ux: 1) vmstat, also shows free memory 2) sar -M ps -eo user,pcpu - does not work, means 'user-defined format'... (4 Replies)
Discussion started by: hp-ux-user
4 Replies

2. HP-UX

How to summary one command's cpu usage?

I want to record one application's(like oracle etc...) CPU usage summary. I can filter by "ps". But how to sum? Thanks (1 Reply)
Discussion started by: jiarong.lu
1 Replies

3. Shell Programming and Scripting

check cpu usage

Hi, Are there previous threads on perl scripts that check the cpu usage and send email whenever this exceeded a certain threshold? Thanks. (3 Replies)
Discussion started by: gholdbhurg
3 Replies

4. UNIX for Dummies Questions & Answers

How check the overall CPU usage of the unix server

Hi All, Can anyone help me.. I want to know the command to check the overall CPU usage of the server. Note: I don't want the CPU usge of each and every process. I just want to know thw aggregate CPU utilization of the server. (2 Replies)
Discussion started by: Selva_Kumar
2 Replies

5. HP-UX

how can I find cpu usage memory usage swap usage and logical volume usage

how can I find cpu usage memory usage swap usage and I want to know CPU usage above X% and contiue Y times and memory usage above X % and contiue Y times my final destination is monitor process logical volume usage above X % and number of Logical voluage above can I not to... (3 Replies)
Discussion started by: alert0919
3 Replies

6. HP-UX

CPU usage per user

Hello everybody, How can we proceed to measure the CPU used par a user on unix HPUX ? there some commands or tools ? Thank you in advance. (4 Replies)
Discussion started by: mlaiti
4 Replies

7. AIX

How to monitor the IBM AIX server for I/O usage,memory usage,CPU usage,network..?

How to monitor the IBM AIX server for I/O usage, memory usage, CPU usage, network usage, storage usage? (3 Replies)
Discussion started by: laknar
3 Replies

8. UNIX for Dummies Questions & Answers

Is total CPU usage for sar %user+%system+%iowait?

Hi all Can anyone advise/confirm whether total CPU usage when running sar is %user+%system+%iowait or is it %user+%system only? I want to confirm whether I am having a CPU-bound problem or not. This is a single-CPU VMware machine. $ sar 5 20 Linux 2.6.18-238.5.1.el5... (7 Replies)
Discussion started by: newbie_01
7 Replies

9. Solaris

How can i restrict user high cpu usage?

HI In my M5000 , one of domain is having SAp installed. from today onwards we are facing some stange issue. when we start SAP application, that particular user is taking 95 % of system CP and renaming 5 % is taken by system . because of this reason application is slow. i have 4 CPU(32... (4 Replies)
Discussion started by: bentech4u
4 Replies

10. Linux

Ps command on cpu usage and time

Hi All, Am very new to Linux and unix ...need below help . need to list of process consuming more than 40% cpu and which are older than 10 days of a particular user .... Thanks V (4 Replies)
Discussion started by: venky456
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 04:32 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy