INVESTIGATING AND MANAGING PROCESS


Investigating and managing process

What is process?
A process is an executing with several components and properties, including a memory context, priority, and environment. The Linux kernel tracks every aspect of a process by its PID under /proc/PID.

 View all processes: 

The "ps" command provides an easy way to view these properties and has several styles of output depending on the option used. Without option, it displays information about processes specific to the active terminal.



Option
Description
a
displays all processes, not including process not controlled by a terminal
x
includes processes not controlled by a terminal, such as deamon processes
u
print process owner information



Note- 
If you want a list of all the processes running on your system, you can run "ps aux" command. You can run "pstree" which displays a tree structure of all processes running on your system.

Example-
#ps -aux
 #pstree

Tracking system activity with "top" command

This utility monitors system activity interactively. When you run "top" command from a shell, it display all the active processes and updates the screen. By default, top updates its every second - an interval you can change by using the "d second" option.
For example: to updates the screen every 5 second runs the "top d 5" command. Process states Every process has a state property, which describes whether the process is actively using the CPU (running), in memory but not doing anything (sleeping), waiting for a resource to become available (uninterrupted sleep) or terminated, but not flushed from the process list (Zombie).

Uninterrupted sleep:
Process is sleeping and cannot be woken up until an event occurs. It cannot be woken up by a signal. 

Zombie:
 Just before a process dies, it sends a signal to its parent and waits for an acknowledgment before terminating. Even if the parent process does not immediately acknowledge this signal, all resources except for the process identity number (PID) are released.


Viewing specific process information 
There may be hundreds of processes on a system, a common technique to locate a specific process is to send output from ps to grep.
#ps axo pid,comm | grep 'cups'
or
 #pgrep cups
or
#pidof cupsd

Signals 
Signals are simple messages that can be communicated to processes with command like kill. Sent directly to processes, no user-interface required. Programs associate action with each signal. Signals are specified by name or number when sent.

Checking memory and I/O with "vmstat" command

The "vmstat" utility also provides Interesting information about processes, memory, I/O, and CPU activity. 
#vmstat





The procs field show the number of processes
r
waiting for run time
b
blocked
w
swapped out




The memory fields show the kilobytes of
 1. swap memory
 2. free memory
 3. buffered memory
 4. cached memory



The swap fields show the kilobytes per second of memory
si
swapped in from disk
so
swapped out from disk


The io fields show the number of blocks per second
bi
sent to block devices
bo
receive from block devices


The system fields show the number of
in
interrupts per second
cs
context switches per second


The CPU fields show the percentage of total CPU time as
us
user time
sy
system time
id
idle time



Note- If you want vmstat to update information automatically, you can run it as "vmstat nsec", where "nsec" is the number of second you want it to wait before another update.

 #vmstat 5



_____________________________________________________________________________________________
Click Back..                                Click Home..