Published on: January 3, 2012 by Vipin R.N
Scenario:
In server monitoring service we have come across the term Process many times and we are here explaining what is mean by a process in Linux systems
Program Vs Process
A process and a thread is almost the same, and the only worthwhile difference between a thread and a process is that threads share the same address space completely and hence require less creation time. Processes are independent execution units that contain their own state information, use their own address spaces, and only interact with each other via inter-process communication mechanisms. A thread is a coding construct that doesn’t affect the architecture of an application. A single process might contains multiple threads; all threads within a process share the same state and same memory space, and can communicate with each other directly, because they share the same variables.
A few process related commands with options:
ps command (process status) will display snapshot information of all active processes.
Use “ps aux”, as shown below.
You can also use “ps -ef | more”, to get a similar output
Use ¨pstree¨ to get output like this:
More information regarding ‘kill’ can be found at the man page
[root@localhost ~]# man kill
Top – Display Linux tasks
The top program provides a dynamic real-time view of a running system. It can display system summary information as well as a list of tasks currently being managed by the Linux kernel.
top – Sort by CPU -> P
Sort by MEM -> M
Sort by PID -> N
Kill by PID -> k
Renice by PID -> r
List by user -> u
Active processes or non idle process -> i
pgrep looks through the currently running processes and lists the process IDs which matches the selection criteria to stdout. All the criteria have to match.
For example, pgrep -u root sshd
The process parent PID, the creator of the process.
These functions return information about the specified file. You do not need any access right to the file to get this information but you need search rights to all directories named in the path to the file.
TTY – Controlling Terminal
It print the file name of the terminal connected to standard input .
[root@localhost ~]# tty
/dev/pts/5
Lower the number, higher the priority, from +19 to -20. The priority numbers available for the system is from +39 to -60, while -20 to -60 is reserved for kernel threads. A normal user can have priorities from 0 to +20, and negative values as well as reducing the values are allowed only to root.
NI – Dynamic priority value , ranges from +19 to -20
TIME – total CPU time used
Process Status (STAT) Codes can be of any of these.
D uninterruptible sleep (usually IO) – cannot be terminated at the moment.
R runnable (on run queue) – can be run
S sleeping – waiting for an external event
T traced or stopped – is suspended.
Z a defunct (“zombie”) process – has terminated itself.
X Extinct – is dead
Setting limits on the number of processes that can run.
The command “ulimit” is used to limit the number of processes users can run along with available system resources. All processes which will be started from the shell (bash in many cases), will have the same resource limits. To set the limits for daemons which are running at boot time add ulimit
command to boot scripts. See apache startup script.
/etc/security/limits.conf
For example:
[root@localhost ~]#ulimit -S -m 1000000 [root@localhost ~]# ulimit -S -v 500000
With this value set, the system will kill any process that tries to take up more resources than you have set as a limit.
For Linux server monitoring service, do contact our server monitoring team with your requirements
Category : General, Howtos, Linux, Special Offers, Training, Troubleshooting
Add new commentSIGN IN