What about something like:
which would then get you a file with '|' character to use as a field separator.
That might make it easier to sort, grep, etc...
Brilliant. Seems like I'll have to take a look at awk. Thanks.
EDIT: OK, seems like you can make it with grep also ... but what's the role of UNIX95 variable?
For my current level, I'll just combine awk and filter out defunct zombies with grep.
---------- Post updated at 03:58 PM ---------- Previous update was at 03:39 PM ----------
Wait ... after awk (ps -eo pid,comm,%cpu | awk '{OFS="|"; print $1,$2,$3}'), how do I sort according to $3 field?
If I cut the 3rd field, I lose the PIDs.
---------- Post updated at 04:04 PM ---------- Previous update was at 03:58 PM ----------
There is a simpler solution ... sort's -k option:
Last edited by courteous; 01-24-2011 at 04:45 PM..
You can sort on any field, or sort defaults to starting at the left.
So, you an keep in the current layout of three (or more/less) fields, and then work with the various sort options. You would specify the a -t option noting the '|' as delimiter. Check into the -n to specify numerics.
Or, awk can print in a different order. You could:
and put the third field first.
Note:
I can see that you are experimenting, and that is good. Where I am right now I am having difficulty recreating your ps command, thus the suggestions are all from memory.
Last edited by joeyg; 01-24-2011 at 05:06 PM..
Reason: Added a final note.
Sorry, but I don't believe that this line is syntactically correct (because of the "%" character) - but I could be wrong.
What Operating System and version you you have? There is much variation in the "ps" command.
Assuming that the syntax is correct on your system (which I do not believe), the "-o" parameter to "ps" allows you to display the parameters in any order.
We don't need "awk" to change the order of the fields. I note that "purdym" knows this.
My version of the HP-UX "Top 10 CPU users" includes:
This can equally be:
The "UNIX95" variable is specific to HP-UX and causes certain commands to behave with Berkeley unix syntax rather than Unix System V syntax. The manual suggests that the default "ps" syntax is "Posix" but that version is inferior to the Berkeley version.
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)
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)
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)
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)
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)
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)
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)
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)
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)