I have a Fedora Core 8 box I ran these on, it should work for Unix and Linux systems:
This command pipes the cleansed output of 'top' to command line and cleans the escape codes.
Quote:
top -cSb n 1
My results: Use this to pipe the cleansed output of 'top' to command line and cut off the unnecessary header lines.
Quote:
top -cSb n 1 | tail -n+8
My Results: How to get the top output for only one pid (process id).
Quote:
top -cSb n 1 -p 3812 | tail -n+8
My results: How to track the cpu usage for a single process in Linux/Unix:
*Important: change the process id '3812' to one of your PID's.
Quote:
top -cSb -p 3812 n 1 | tail -n+8 | sort -rn -k5 | awk 'NR > 0 { s +=$9 }; END {print "cpu %",s}'
My Results:
For some reason the 'ps' command does not come out with the same results as top does (based on my observation). Top yields the most accurate summary of how much CPU your process is using.
You could also use ps to figure out how much total CPU load in Linux/Unix.
Quote:
ps aux|awk 'NR > 0 { s +=$3 }; END {print "cpu %",s}'
I make no guarantees for this command, it seems to match up with top's version, however if you have a dual core, or more than one core, this number returned will go to 200%. It's a hack.
My Results:
This was the command that satisfied my problem:
replace 12345 with your PID:
Last edited by sentientmachine; 05-21-2009 at 06:16 PM..
Hi,
We have a DEC Alpha 4100 Server with OSF1 Digital Unix 4.0.
Can any one tell me, if there are any commands on this Unix which are equivalent to "top" and "sar" on HP-UX or Sun Solaris ?
I am particularly interested in knowing the CPU Load, what process is running on which CPU, etc.
... (1 Reply)
Hi,
I have a process that can be seen after "ps aux" command.
However when I do "top" command. This process
cannot be seen.
How can this happen? Is there anything wrong
with my code? (3 Replies)
Hi All,
I am running my application on a dual cpu debian linux 3.0 (2.4.19 kernel).
For my application:
<sar -U ALL>
CPU %user %nice %system %idle
...
10:58:04 0 153.10 0.00 38.76 0.00
10:58:04 1 3.88 0.00 4.26 ... (0 Replies)
Hi All,
I have working (Perl) code to combine 2 input files into a single output file using the join function that works to a point, but has the following limitations:
1. I am restrained to 2 input files only.
2. Only the "matched" fields are written out to the "matched" output file and... (1 Reply)
Hi,
I am trying to get the system RAM size from "top" command's output by the following but it is not working.
top | sed "s/^Mem.**\(*\), *//" (10 Replies)
Hi,
I have line in input file as below:
3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL
My expected output for line in the file must be :
"1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL"
Can someone... (7 Replies)
Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known data:
I am required to create a bash shell script with either emacs or vi. It must include the year 2014 calendar on... (9 Replies)
How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address
and column 3 contains “cc” e-mail address to include with same email.
Sample input file, email.txt
Below is an sample code where... (2 Replies)
Hello.
System : opensuse leap 42.3
I have a bash script that build a text file.
I would like the last command doing :
print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt
where :
print_cmd ::= some printing... (1 Reply)