Wednesday, September 12, 2012

Check the Process id and Process states

 [root@crs2 ~]# ps -aux | less


USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.0  0.0   2040   632 ?        Ss   09:30   0:00 init [5]     
                    
root         2  0.0  0.0      0     0 ?        S    09:30   0:00 [migration/0]
root         3  0.0  0.0      0     0 ?        SN   09:30   0:00 [ksoftirqd/0]
root         4  0.0  0.0      0     0 ?        S    09:30   0:00 [watchdog/0]
root         5  0.0  0.0      0     0 ?        S<   09:30   0:00 [events/0]
root         6  0.0  0.0      0     0 ?        S<   09:30   0:00 [khelper]
root         7  0.0  0.0      0     0 ?        S<   09:30   0:00 [kthread]
root        10  0.0  0.0      0     0 ?        S<   09:30   0:00 [kblockd/0]
root        11  0.0  0.0      0     0 ?        S<   09:30   0:00 [kacpid]
root       180  0.0  0.0      0     0 ?        S<   09:30   0:00 [cqueue/0]
root       183  0.0  0.0      0     0 ?        S<   09:30   0:00 [khubd]
root       185  0.0  0.0      0     0 ?        S<   09:30   0:00 [kseriod]
root       249  0.0  0.0      0     0 ?        S    09:30   0:00 [pdflush]
root       250  0.0  0.0      0     0 ?        S    09:30   0:00 [pdflush]
:



You can check the process id and states of process using the below command and syntax.

[root@crs2 ~]# ps -C init -o pid=,cmd,stat
      CMD                         STAT
    1 init [5]                    Ss

[root@crs2 ~]# ps -C firefox -o pid=,cmd,stat
      CMD                         STAT
 6666 /bin/sh /usr/lib/firefox-1. S

 Processes states that ps indicate are:

D Uninterruptible sleep (usually IO)
R Running or runnable (on run queue)
S Interruptible sleep (waiting for an event to complete)
T Stopped, either by a job control signal or because it is being traced.
W paging (not valid since the 2.6.xx kernel)
X dead (should never be seen)
Z Defunct ("zombie") process, terminated but not reaped by its parent.

< high-priority (not nice to other users)
N low-priority (nice to other users)
L has pages locked into memory (for real-time and custom IO)
s is a session leader
l is multi-threaded (using CLONE_THREAD, like NPTL pthreads do)
+ is in the foreground process group

No comments: