快速业务通道

linux进程学习

作者 佚名技术 来源 Linux系统 浏览 发布时间 2012-04-27

redhat server 2.6.x进程学习笔记

概要:进程概念;ps,pstree,top,kill,进程状态;man ps;

[root@server1 /]#
[root@server1 /]# ps
PID TTY TIME CMD
4973 pts/0 00:00:00 bash
6326 pts/0 00:00:00 man
6329 pts/0 00:00:00 sh
6330 pts/0 00:00:00 sh
6335 pts/0 00:00:00 less
6381 pts/0 00:00:00 ps
[root@server1 /]# man ps

ps - report a snapshot of the current processes.

ps [options]

DESCRIPTION
ps displays information about a selection of the active processes. If you want a repetitive update of theselection and the displayed information, use top(1) instead.

This version of ps accepts several kinds of options:
1 UNIX-style options, which may be grouped and must be preceded by a dash.
2 BSD-style options, which may be grouped and must not be used with a dash.
3 GNU-style long options, which are preceded by two dashes.

By default, ps selects all processes with the same effective user ID (euid=EUID) as the current user and associated with the same terminal as the invoker(非故意的; 偶然的). It displays the process ID (pid=PID), the terminal associated with the process (tname=TTY), the cumulated(累积) CPU time in [dd-]hh:mm:ss format (time=TIME), and the executable name (ucmd=CMD). Output is unsorted by default.

To see every process on the system using standard syntax:
ps -e
ps -ef
ps -eF
ps -ely

To see every process on the system using BSD syntax:
ps ax
ps axu

To print a process tree:
ps -ejH
ps axjf

To get info about threads:
ps -eLf
ps axms

To get security info:
ps -eo euser,ruser,suser,fuser,f,comm,label
ps axZ
ps –eM

To see every process running as root (real & effective ID) in user format:
ps -U root -u root u

This ps works by reading the virtual files in /proc. This ps does not need to be setuid kmem or have any privileges to run. Do not give this ps any special permissions.

This ps needs access to namelist data for proper WCHAN display. For kernels prior to 2.6, the System.map file must be installed.

CPU usage is currently expressed as the percentage of time spent running during the entire lifetime of a process. This is not ideal, and it does not conform to the standards that ps otherwise conforms to. CPU usage is
unlikely to add up to exactly 100%.

PROCESS STATE CODES
Here are the different values that the s, stat and state output specifiers (header "STAT" or "S") will display
to describe the state of a process.
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.

For BSD

凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!

分享到: 更多

Copyright ©1999-2011 厦门凌众科技有限公司 厦门优通互联科技开发有限公司 All rights reserved

地址(ADD):厦门软件园二期望海路63号701E(东南融通旁) 邮编(ZIP):361008

电话:0592-5908028 传真:0592-5908039 咨询信箱:web@lingzhong.cn 咨询OICQ:173723134

《中华人民共和国增值电信业务经营许可证》闽B2-20100024  ICP备案:闽ICP备05037997号