发表于: lnmp | 作者: | 日期: 2009/7/11 12:07
标签:

功能说明
ps是linux/unix下一个强大的进程查看命令,可以查看当前进程的状态。

我比较常用的格式
1、

ps -u bossweb -f

输出如下:

UID PID PPID C STIME TTY TIME CMD
bossweb 3346570 3379430 0 May 31 pts/2 0:00 vi blank.jsp
bossweb 3379430 1732740 0 May 31 pts/2 0:00 -ksh
bossweb 3707000 2789476 0 23:41:54 pts/3 0:00 tail -f console.log
bossweb 3989732 2293920 0 19:35:29 pts/14 0:00 /bin/sh ./startWebLogic.sh
bossweb 4264066 548906 0 23:35:04 – 0:00 ftpd
bossweb 5230614 1 0 23:41:52 pts/3 0:00 sh startWebLogic.sh
bossweb 5750852 5910550 1 23:48:35 pts/5 0:00 -ksh

使用全格式显示用户bossweb所有的进程。输出中每列的含义如下:
UID
用户名。

PID
进程ID

PPID
进程父ID

C
CPU利用率,以整数表示。

STIME
进程的启动时间

TTY
表示终端

TIME
进程使用CPU累计时间

CMD
运行该进程的命令

2、

ps -aux

输出如下:

UID PID TTY TIME CMD
702 1147024 pts/46 0:00 sqlplus
703 1253594 pts/6 0:00 telnet
702 1601730 pts/12 0:00 vi
702 1724590 pts/17 0:00 sqlplus
703 1794154 pts/1 0:00 telnet
702 2060462 pts/8 0:00 vi
703 2338920 pts/13 0:00 telnet
702 2736210 pts/11 0:00 sqlplus
703 2789476 pts/3 0:00 ksh
703 3023050 pts/14 2:06 java
703 3059740 pts/3 1:17 java
702 3141802 pts/11 0:00 vi
703 3346570 pts/2 0:00 vi
703 3707000 pts/3 0:00 tail
703 3989732 pts/14 0:00 sh
702 5009598 pts/10 0:00 sqlplus
703 5230614 pts/3 0:00 sh
702 5853274 pts/9 0:00 telnet
703 6213700 pts/5 0:00 ps

语  法
X/Open Standards
ps [ -A ] [ -M ] [ -N ] [ -a ] [ -d ] [ -e ] [ -f ] [ -k ] [ -l ] [ -F format] [ -o Format ] [ -c Clist ] [ -G Glist ] [ -g Glist ] [ -m ] [ -n NameList ] [ -p Plist ] [ -P ] [ -t Tlist ] [ -U Ulist ] [ -u Ulist ] [ -T pid ] [ -L pidlist ] [ -X ]

Berkeley Standards
ps [ a ] [ c ] [ e ] [ ew ] [ eww ] [ g ] [ n ] [ U ] [ w ] [ x ] [ l | s | u | v ] [ t Tty ] [ X ] [ ProcessNumber ]

参  数(网络copy过来的,没有一一测试,仅供参考。)
-A  
显示所有程序。

-M
Lists all 64 bit processes.

-N
显示所有的程序,除了执行ps指令终端机下的程序之外。

-a  
显示所有终端机下执行的程序,除了阶段作业领导者之外。英文原文是:Writes to standard output information about all processes, except the session leaders and processes not associated with a terminal.

-d  
显示所有程序,但不包括阶段作业领导者的程序。

-e  
此参数的效果和指定”A”参数相同。

-f  
显示UID,PPIP,C与STIME栏位。

-k
Lists kernel processes.

-l或l  
采用详细的格式来显示程序状况。

-F Format
Same as -o Format

-o Format
Displays information in the format specified by the Format variable. Multiple field specifiers can be specified for
the Format variable. The Format variable is either a comma-separated list of field specifiers or a list of field
specifiers enclosed within a set of ” ” (double-quotation marks) and separated from one another by a comma or by one
or more spaces, or both.

-c  
显示CLS和PRI栏位。

c  
列出程序时,显示每个程序真正的指令名称,而不包含路径,参数或常驻服务的标示。

-C<指令名称>  
指定执行指令的名称,并列出该指令的程序的状况。

-g<群组名称>  
此参数的效果和指定”-G”参数相同,当亦能使用阶段作业领导者的名称来指定。

g  
显示现行终端机下的所有程序,包括群组领导者的程序。

-G<群组识别码>  
列出属于该群组的程序的状况,也可使用群组名称来指定。

h  
不显示标题列。

-H  
显示树状结构,表示程序间的相互关系。

-j或j  
采用工作控制的格式显示程序状况。

L  
列出栏位的相关信息。

-m或m  
显示所有的执行绪。

n  
以数字来表示USER和WCHAN栏位。

-p<程序识别码>  
指定程序识别码,并列出该程序的状况。

p<程序识别码>  
此参数的效果和指定”-p”参数相同,只在列表格式方面稍有差异。

r  
只列出现行终端机正在执行中的程序。

-s<阶段作业>  
指定阶段作业的程序识别码,并列出隶属该阶段作业的程序的状况。

s  
采用程序信号的格式显示程序状况。

S  
列出程序时,包括已中断的子程序资料。

-t<终端机编号>  
指定终端机编号,并列出属于该终端机的程序的状况。

t<终端机编号>  
此参数的效果和指定”-t”参数相同,只在列表格式方面稍有差异。

-T  
显示现行终端机下的所有程序。

-u<用户识别码>  
此参数的效果和指定”-U”参数相同。

u  
以用户为主的格式来显示程序状况。

-U<用户识别码>  
列出属于该用户的程序的状况,也可使用用户名称来指定。

U<用户名称>  
列出属于该用户的程序的状况。

v  
采用虚拟内存的格式显示程序状况。

-V或V  
显示版本信息。

-w或w  
采用宽阔的格式来显示程序状况。 

x  
显示所有程序,不以终端机来区分。

X  
采用旧式的Linux i386登陆格式显示程序状况。

-y  
配合参数”-l”使用时,不显示F(flag)栏位,并以RSS栏位取代ADDR栏位。

–<程序识别码>  
此参数的效果和指定”p”参数相同。


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

从AIX的man手册里copy出来几个例子,以备参考:

Examples
1 To display all processes, type:

ps -e -f
To display all processes with expanded user name, type:

ps -X -e -f
2 To list processes owned by specific users, type:

ps -f -l -ujim,jane,su
3 To list processes that are associated with the /dev/console and /dev/tty1 ttys, type:

ps -t console,tty/1
4 To list processes not associated with a terminal, type:

ps -t –
5 To display a specified format with field specifiers, type:

ps -o ruser,pid,ppid=parent,args

The output is:

RUSER PID parent COMMAND
helene 34 12 ps -o ruser,pid,ppid=parent,args
6 To display a specified format with field descriptors, type:

ps -o “< %u > %p %y : %a”

The output is:

< RUSER > PID TT : COMMAND
< helene > 34 pts/3 : ps -o < %u > %p %y : %a
7 To display information about processes and kernel threads controlled by the current terminal, type:

ps -lm

The output is similar to:

F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD
240003 A 26 8984 7190 1 60 20 2974 312 pts/1 0:00 -ksh
400 S – – – 1 60 – – – – – –
200005 A 26 9256 8984 15 67 20 18ed 164 pts/1 0:00 ps
0 R – – – 15 67 – – – – – –
8 To display information about all processes and kernel threads, type:

ps -emo THREAD

The output is similar to:

USER PID PPID TID S C PRI SC WCHAN FLAG TTY BND CMD
jane 1716 19292 – A 10 60 1 * 260801 pts/7 – biod
– – – 4863 S 0 60 0 599e9d8 8400 – – –
– – – 5537 R 10 60 1 5999e18 2420 – 3 –
luke 19292 18524 – A 0 60 0 586ad84 200001 pts/7 – -ksh
– – – 7617 S 0 60 0 586ad84 400 – – –
luke 25864 31168 – A 11 65 0 – 200001 pts/7 – –
– – – 8993 R 11 65 0 – 0 – – –
9 To list all the 64-bit processes, type:

ps -M
10 To display the project assignment details for the processes, type:

ps -P

: https://blog.darkmi.com/2009/07/11/888.html

本文相关评论 - 1条评论都没有呢
Post a comment now » 本文目前不可评论

No comments yet.

Sorry, the comment form is closed at this time.