Jyothi's Weblog

« Changing BIOS settin... | Main | Partitioning and... »

http://blogs.sun.com/jyothi/date/20070328 Wednesday March 28, 2007

Using ps

The process is the heart of the UNIX system. It is a program in operation and is identified by its unique process id (PID). The common command to list process information is ps. There are 2 flavors of ps,  /usr/bin/ps (from SVR4 ) and /usr/ucb/ps (from BSD). The following is valid only for /usr/bin/ps.

$ ps -ef

prints information about every process(-e) that is running with full (-f) details.

 Here is a brief description of the output columns for ps :

Column 1 : User id(UID)

Column 2 : Unique process id for the process(PID)

Column 3:  Parent Id for the process(PPID)

Column 4: C - According to the man pages, it is "Processor utilization for scheduling(obsolete)". This represents the CPU utilization factor.

Column 5 : Start time of the process in hours,minutes and seconds(STIME)

Column 6 :The controlling terminal for the process ; ? is printed when there is no controlling terminal(TTY).

Column 7 : Time consumed by CPU for the process. If this number is high,it may mean that the process is hogging the CPU (TIME).

Column 8 : The command name that initiated the process.(CMD).

Here are some examples of ps :

$ ps -ef  | grep <uid>

prints all processes for userid

You can send (redirect) the output of ps (or any other command) to a file by typing

$ ps -ef  | grep userid   filename

To append the output to a file, type

$ ps -ef | grep username   >> filename

To find the process ids of all users running firefox, for example, type

$ ps -ef  | grep -i firefox | awk '{print $2}'

where $2 refers to the PID (2nd column) in the output for ps.

To print the pid of a particular user running firefox, type

$ ps -ef  | grep userid | grep -i firefox  | awk '{print $2}'

You can also specify the arguments to be outputted with the -o option. This example prints the user id,process id,percentage of recent CPU usage and the command that initiated the process for a particular user.

$ ps -eo user,pid,pcpu,comm | grep userid

You can find more examples on using ps on Sun's BigAdmin website here .

 

 

Comments:

If you like that, you will *love* the ptools (ptree, pgrep, pstack, pldd, etc.) - start with 'man pgrep' .

Posted by Dick Davies on March 28, 2007 at 05:15 PM PDT #

http://www.batterylaptoppower.com/toshiba/pa3356u-1brs-002.php 8.8ah Battery TOSHIBA PA3356U-1BAS PA3356U-1BRS PA3356U-2BRS laptop battery ,
http://www.batterylaptoppower.com/toshiba/pa3335u-1bas.php battery fits TOSHIBA PA3399U-1BAS PA3399U-1BRS 6600mAH laptop battery ,
http://www.batterylaptoppower.com/toshiba/pa3534u-1brs.php NEW Genuine Toshiba Battery Satellite PA3534U-1BRS A205 laptop battery ,

Posted by new battery on November 05, 2008 at 07:50 PM PST #

Post a Comment:
Comments are closed for this entry.

Valid HTML! Valid CSS!

This is a personal weblog, I do not speak for my employer.