Sponsored Content
Top Forums Shell Programming and Scripting Print 10 most CPU-intensive processes (wo/ top) Post 302490336 by purdym on Monday 24th of January 2011 03:33:54 PM
Old 01-24-2011
First you need the processes and the information you want, then you have to format the output.

On HP-UX I use:

Code:
   export UNIX95=1
   ps -efH -o pcpu,user,nice,cpu,pid,args |  grep -vE "^ *0\.0|defunct|CPU|high_cpu|init" >$LOG_FILE1

Then you need to 'sort' the information:
Code:
sort -T $SORT_DIR -r -n -k 1

And if you only want the top 10, use
Code:
head

Finally:
Ex:
Code:
high_cpu

CPU    User       Nice   CPU  PID        Command
------------------------------------------------------------------------------------------------------------------------------------
96.07  root       20     244  2453       /opt/wbem/lbin/cimprovagt 0 5 10 root SFMProviderModule
25.82  brm01dev   22     209  17528      oracledps01dvu (LOCAL=NO)
19.47  brm01dev   22     228  2669       oracledps02dvu (LOCAL=NO)
4.59   brm01dev   22     28   18894      oracledps01dvu (LOCAL=NO)
3.83   brm01dev   22     26   18508      oracledps01dvu (LOCAL=NO)
3.64   dpsdev     22     27   8961       oraclegendvu (LOCAL=NO)
2.11   brm01dev   22     6    17805      oracledps01dvu (LOCAL=NO)
1.66   pasdev     22     17   3499       oraclepasdvu (LOCAL=NO)
1.33   root       20     0    80         pagezerod
1.23   brm01dev   22     13   13796      /oracle/pasdev/app/product/10.2.brm/bin/tnslsnr listenerbrm01dev -inherit
1.03   brm01dev   22     10   8500       oracledps02dvu (LOCAL=NO)
1.01   brm01dev   22     8    2093       ora_dbw0_dps02dvu
0.98   brm01dev   22     29   8476       oracledps02dvu (LOCAL=NO)
0.78   root       20     0    3023       /opt/perf/bin/midaemon
0.65   root       20     9    8407       sshd: purdym [priv]
0.58   root       20     0    3294       /usr/lbin/utild

This User Gave Thanks to purdym For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How Can I Have Top Display The Top 20 Processes??

how can i do that in a script withough havin the script halt at the section where the top command is located. am writign a script that will send me the out put of unx commands if the load average of a machine goes beyond the recommended number. top -n 20 i want to save this output to a file... (1 Reply)
Discussion started by: TRUEST
1 Replies

2. UNIX for Dummies Questions & Answers

Dual CPU's and 'top'

Hi have just built a new sunfire 280r with solaris 9 and i Have 2 questions 1) where can i view some information that will tell me for definate that the 2*900 mhz processors are both being used, i tried using "top" but it doesnt tell me for sure that both processors are churning away together ... (3 Replies)
Discussion started by: hcclnoodles
3 Replies

3. UNIX for Advanced & Expert Users

top %CPU.

I am using the Red Hat Enterprise Linux AS release 3 (Taroon), 2.4.21-4.EL. When I see the output of the command 'top'. I am getting the following ************************************************************************************ 2 processes: 227 sleeping, 5 running, 0 zombie, 0 stopped... (3 Replies)
Discussion started by: praveen_b744
3 Replies

4. 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

5. AIX

Need a list of top 10 CPU using processes (also top 10 memory hogs, separately)

Okay, I am trying to come up with a multi-platform script to report top ten CPU and memory hog processes, which will be run by our enterprise monitoring application as an auto-action item when the CPU and Memory utilization gets reported as higher than a certain threshold I use top on other... (5 Replies)
Discussion started by: thenomad
5 Replies

6. UNIX for Dummies Questions & Answers

How To Scroll Processes In top?

I'm using top to view processes. But, I do not know how to scroll down the list to view what is not showed in the terminal window. Anyone know how to do this? (1 Reply)
Discussion started by: keenansnews
1 Replies

7. Solaris

top is showing 0% cpu Idle

What should we do if we show a 0% cpu idl on top? (5 Replies)
Discussion started by: Pouchie1
5 Replies

8. Shell Programming and Scripting

Warning in Top 10 cpu consuming processes

I m using following command to find top 10 cpu consuming processes. However whenever i execute the command i get following warning. What can be done to avoid it? # ps -auxf | sort -nr -k 3 | head -10 Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.7/FAQ root ... (6 Replies)
Discussion started by: pinga123
6 Replies

9. Shell Programming and Scripting

Need a script to see top processes for every hour

Hi All, I am new to Scripting , please give me guidance to write the script to see top processes on the Linux operating system. I executed this script on my Virtual Server(Linux) DATE=`date +%Y%m%d%H%M%S` HOME=/home/xmp/testing/xmp_report RADIUS_PID=`xms -xmp sh pr | grep... (2 Replies)
Discussion started by: madala
2 Replies

10. Shell Programming and Scripting

Record top accessed processes/files

Hello, I have about 100 servers that I'm looking to collect information regarding top files and processes accessed within a 168 hr (1 week) period. Each server has a different purpose and so different installed applications. All servers are running either unix or linux. What would be a... (0 Replies)
Discussion started by: umang2382
0 Replies
SYSTEMD-RC-LOCAL-GENERATOR(8)				    systemd-rc-local-generator				     SYSTEMD-RC-LOCAL-GENERATOR(8)

NAME
systemd-rc-local-generator - Compatibility generator for starting /etc/rc.local and /usr/sbin/halt.local during boot and shutdown SYNOPSIS
/lib/systemd/system-generators/systemd-rc-local-generator DESCRIPTION
systemd-rc-local-generator is a generator that checks whether /etc/rc.local exists and is executable, and if it is pulls the rc-local.service unit into the boot process. This unit is responsible for running this script during late boot. Note that the script will be run with slightly different semantics than the original System V version, which was run "last" in the boot process, which is a concept that does not translate to systemd. The script is run after network.target, but in parallel with most other regular system services. systemd-rc-local-generator also checks whether /usr/sbin/halt.local exists and is executable, and if it is pulls the halt-local.service unit into the shutdown process. This unit is responsible for running this script during later shutdown. Support for both /etc/rc.local and /usr/sbin/halt.local is provided for compatibility with specific System V systems only. However, it is strongly recommended to avoid making use of these scripts today, and instead provide proper unit files with appropriate dependencies for any scripts to run during the boot or shutdown processes. systemd-rc-local-generator implements systemd.generator(7). SEE ALSO
systemd(1), systemctl(1) systemd 237 SYSTEMD-RC-LOCAL-GENERATOR(8)
All times are GMT -4. The time now is 04:25 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy