how to print the values of pcpu of any process in unix


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers how to print the values of pcpu of any process in unix
# 1  
Old 11-13-2008
how to print the values of pcpu of any process in unix

hiiiiiiiiii
this is shyam.i have written a code that it will take the process id of any process and using it print the value of pcpu etc but the problem is it prints
the same value every time it is in loop the code for this is given below.


while true
do
y=`ps -p $pid -o pid,ppid,user,group,pcpu,pmem,rss,osz,vsz,comm`
echo "$y"
sleep 1s
done
i want to print all the frquently changing values .
can anyone please help me
# 2  
Old 11-13-2008
Maybe watch comes close to what you are searching for:
watch ps -p $pid -o pid,ppid,user,group,pcpu,pmem,rss,osz,vsz,comm
# 3  
Old 11-13-2008
Quote:
Originally Posted by ronit_ok2000
hiiiiiiiiii
this is shyam.i have written a code that it will take the process id of any process and using it print the value of pcpu etc but the problem is it prints
the same value every time it is in loop the code for this is given below.


while true
do
y=`ps -p $pid -o pid,ppid,user,group,pcpu,pmem,rss,osz,vsz,comm`
echo "$y"
sleep 1s
done
i want to print all the frquently changing values .
can anyone please help me
thanks for ur advice but the thing i want to happen is to print different values of pcpu or pmem at intervals
13 1 root root 0.8 0 05:51:11 0.0 0 0 0 [kjournald]
13 1 root root 0.8 0 05:51:11 0.0 0 0 0 [kjournald]
13 1 root root 0.8 0 05:51:11 0.0 0 0 0 [kjournald]
13 1 root root 0.8 0 05:51:11 0.0 0 0 0 [kjournald]
13 1 root root 0.8 0 05:51:11 0.0 0 0 0 [kjournald]
13 1 root root 0.8 0 05:51:11 0.0 0 0 0 [kjournald]
13 1 root root 0.8 0 05:51:11 0.0 0 0 0 [kjournald]
13 1 root root 0.8 0 05:51:11 0.0 0 0 0 [kjournald]
13 1 root root 0.8 0 05:51:11 0.0 0 0 0 [kjournald]
this is the output where 0.8 is pcpu but everytime it is 0.8
but originally it is varying and i want pcpu to be varying everytime
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk print odd values

value=$(some command) for all in `echo $value` do awk checks each value (all) to see if it is a odd number. if so, prints the value done sounds easy enough but i've been unable to find anything on google. (2 Replies)
Discussion started by: SkySmart
2 Replies

2. Red Hat

Upgrading a system from two pCPU to four pCPU, need RHEL reinstall?

Hello guys, I'm running RHEL on a Cisco UCS system provided by four CPU sockets but with only two CPUs filled in (so two CPU sockets are empty). I'd like to upgrade my system adding two other CPUs (of the same type). Do I need to reinstall the OS after the upgrade or RHEL will seamlessly manage... (3 Replies)
Discussion started by: azzo1
3 Replies

3. Shell Programming and Scripting

awk Print New Column For Every Two Lines and Match On Multiple Column Values to print another column

Hi, My input files is like this axis1 0 1 10 axis2 0 1 5 axis1 1 2 -4 axis2 2 3 -3 axis1 3 4 5 axis2 3 4 -1 axis1 4 5 -6 axis2 4 5 1 Now, these are my following tasks 1. Print a first column for every two rows that has the same value followed by a string. 2. Match on the... (3 Replies)
Discussion started by: jacobs.smith
3 Replies

4. Shell Programming and Scripting

How to print huge values in sqlplus variable in UNIX?

Hi, I ahve a unix code as below. sqlTxt=$* sqlReturn=`echo "set feedback off; set heading off; set term off; set verify off; set serveroutput on size unlimited set lin 1000; VARIABLE GV_return_val NUMBER; VARIABLE GV_script_error varchar2(4000); EXEC :GV_return_code := 0; EXEC... (6 Replies)
Discussion started by: bhaski2012
6 Replies

5. Shell Programming and Scripting

Compare values in two files. For matching rows print corresponding values from File 1 in File2.

- I have two files (File 1 and File 2) and the contents of the files are mentioned below. - I am trying to compare the values of Column1 of File1 with Column1 of File2. If a match is found, print the corresponding value from Column2 of File1 in Column5 of File2. - I tried to modify and use... (10 Replies)
Discussion started by: Santoshbn
10 Replies

6. Shell Programming and Scripting

print average of values

Is it possible to print the average of 2 nd column based on a key in 1st col input a1X 4 a1X 6 a2_1 10 a2_1 20 a2_1 30 a2_1 30 a2_1 10 output a1X 5 a2_1 20 (11 Replies)
Discussion started by: quincyjones
11 Replies

7. Shell Programming and Scripting

print unique values of a column and sum up the corresponding values in next column

Hi All, I have a file which is having 3 columns as (string string integer) a b 1 x y 2 p k 5 y y 4 ..... ..... Question: I want get the unique value of column 2 in a sorted way(on column 2) and the sum of the 3rd column of the corresponding rows. e.g the above file should return the... (6 Replies)
Discussion started by: amigarus
6 Replies

8. Shell Programming and Scripting

Shell Script to Kill Process(number of process) Unix/Solaris

Hi Experts, we do have a shell script for Unix Solaris, which will kill all the process manullay, it used to work in my previous env, but now it is throwing this error.. could some one please help me to resolve it This is how we execute the script (and this is the requirement) ... (2 Replies)
Discussion started by: jonnyvic
2 Replies

9. Shell Programming and Scripting

print decimal values

Hi guys I'm trying to print average of 2 columns. awk '{print ($1+$2)/2}' file.txt Its printing average but not giving decimal values its giving 3.05521e+08 instead of 305521.... I tried %f to print float values but not quiet connected Could you help plz:confused: (5 Replies)
Discussion started by: repinementer
5 Replies

10. HP-UX

Print Problem in UNIX. Need to know the option to specify the print paper size

Hi, Could any one please let me know what is the option available in UNIX to print by specifying the paper size? We are using Unix11i. I could n't see any option specified in the 'lp' command to print the report by specifying the size of the paper. It would be of great help to me, if... (1 Reply)
Discussion started by: ukarthik
1 Replies
Login or Register to Ask a Question