ps命令实用方法.ps -l ps -L详解
2015-07-16 18:27
501 查看
一、统计sleep状态的进程.
c233 plugins # ps -elf|head -1
F S UID PID PPID C PRI NI ADDR SZ WCHAN STIME TTY TIME CMD
4 S root 28149 4204 0 80 0 - 16283 poll_s Jul05 ? 00:00:00 sshd: root
c233 plugins # ps -efl|awk '$2~/S/{print $0}'|wc -l //-l long format.
73
解释===>
(1)F列.
PROCESS FLAGS
The sum of these values is displayed in the "F" column, which is provided by the flags output specifier.
1 forked but didn't exec
4 used super-user privileges
(1)S列.
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.
(3)C列.C pcpu cpu utilization
(4)
command COMMAND see args. (alias args, cmd).
sz SZ size in physical pages of the core image of the process. This
includes text, data, and stack space. Device mappings are currently
excluded; this is subject to change. See vsz and rss.
(5)WCHAN列.
wchan WCHAN name of the kernel function in which the process is sleeping,
a "-" if the process is running, or a "*" if the process is
multi-threaded and ps is not displaying threads.
二、统计当前运行的线程总数."-L"
c233 plugins # ps -eLf|grep -v $$|wc -l //-L Show threads, possibly with LWP and NLWP columns
646
c233 plugins # ps -eLf|grep -v $$|tail
UID PID PPID LWP C NLWP STIME TTY TIME CMD
root 23678 1 688 0 36 Jul01 ? 00:00:06 /usr/sbin/nscd
root 23678 1 689 0 36 Jul01 ? 00:00:06 /usr/sbin/nscd
root 23678 1 690 0 36 Jul01 ? 00:00:06 /usr/sbin/nscd
root 23678 1 691 0 36 Jul01 ? 00:00:06 /usr/sbin/nscd
root 23678 1 692 0 36 Jul01 ? 00:00:06 /usr/sbin/nscd
root 23678 1 693 0 36 Jul01 ? 00:00:06 /usr/sbin/nscd
root 23678 1 694 0 36 Jul01 ? 00:00:06 /usr/sbin/nscd
root 23678 1 695 0 36 Jul01 ? 00:00:06 /usr/sbin/nscd
root 23678 1 696 0 36 Jul01 ? 00:00:06 /usr/sbin/nscd
root 28149 4204 28149 0 1 Jul05 ? 00:00:00 sshd: root
NLWP (number of threads)
LWP (thread ID)
c233 plugins # ps -ef|grep nscd
root 23678 1 0 Jun30 ? 00:15:32 /usr/sbin/nscd
三、Linux下查看某个进程的线程数量.
1.根据进程号进行查询:
# pstree -p 进程号 //-p pid
# top -Hp 进程号 //-H : Threads toggle
2.根据进程名字进行查询:
# pstree -p `ps -e | grep sshd | awk '{print $1}'`
# pstree -p `ps -e | grep sshd | awk '{print $1}'` | wc -l
四、统计正在sleeop的线程总数.
d231 ~ # for i in `ps aux|awk '$8~/S/{print $2}'`;do //如何让其累加??如何查看正在运行的线程????
> m=`pstree -p $i|wc -l`
> echo $m
> done
No such user name: PID
0
1184
42
1
1
13
1
1
1
1
1
1
1
1
2
2
0
0
61
1
8
1
1088
1
c233 plugins # ps -elf|head -1
F S UID PID PPID C PRI NI ADDR SZ WCHAN STIME TTY TIME CMD
4 S root 28149 4204 0 80 0 - 16283 poll_s Jul05 ? 00:00:00 sshd: root
c233 plugins # ps -efl|awk '$2~/S/{print $0}'|wc -l //-l long format.
73
解释===>
(1)F列.
PROCESS FLAGS
The sum of these values is displayed in the "F" column, which is provided by the flags output specifier.
1 forked but didn't exec
4 used super-user privileges
(1)S列.
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.
(3)C列.C pcpu cpu utilization
(4)
command COMMAND see args. (alias args, cmd).
sz SZ size in physical pages of the core image of the process. This
includes text, data, and stack space. Device mappings are currently
excluded; this is subject to change. See vsz and rss.
(5)WCHAN列.
wchan WCHAN name of the kernel function in which the process is sleeping,
a "-" if the process is running, or a "*" if the process is
multi-threaded and ps is not displaying threads.
二、统计当前运行的线程总数."-L"
c233 plugins # ps -eLf|grep -v $$|wc -l //-L Show threads, possibly with LWP and NLWP columns
646
c233 plugins # ps -eLf|grep -v $$|tail
UID PID PPID LWP C NLWP STIME TTY TIME CMD
root 23678 1 688 0 36 Jul01 ? 00:00:06 /usr/sbin/nscd
root 23678 1 689 0 36 Jul01 ? 00:00:06 /usr/sbin/nscd
root 23678 1 690 0 36 Jul01 ? 00:00:06 /usr/sbin/nscd
root 23678 1 691 0 36 Jul01 ? 00:00:06 /usr/sbin/nscd
root 23678 1 692 0 36 Jul01 ? 00:00:06 /usr/sbin/nscd
root 23678 1 693 0 36 Jul01 ? 00:00:06 /usr/sbin/nscd
root 23678 1 694 0 36 Jul01 ? 00:00:06 /usr/sbin/nscd
root 23678 1 695 0 36 Jul01 ? 00:00:06 /usr/sbin/nscd
root 23678 1 696 0 36 Jul01 ? 00:00:06 /usr/sbin/nscd
root 28149 4204 28149 0 1 Jul05 ? 00:00:00 sshd: root
NLWP (number of threads)
LWP (thread ID)
c233 plugins # ps -ef|grep nscd
root 23678 1 0 Jun30 ? 00:15:32 /usr/sbin/nscd
三、Linux下查看某个进程的线程数量.
1.根据进程号进行查询:
# pstree -p 进程号 //-p pid
# top -Hp 进程号 //-H : Threads toggle
2.根据进程名字进行查询:
# pstree -p `ps -e | grep sshd | awk '{print $1}'`
# pstree -p `ps -e | grep sshd | awk '{print $1}'` | wc -l
四、统计正在sleeop的线程总数.
d231 ~ # for i in `ps aux|awk '$8~/S/{print $2}'`;do //如何让其累加??如何查看正在运行的线程????
> m=`pstree -p $i|wc -l`
> echo $m
> done
No such user name: PID
0
1184
42
1
1
13
1
1
1
1
1
1
1
1
2
2
0
0
61
1
8
1
1088
1
相关文章推荐
- Maven Missing Artifact 问题(ezmorph, json-lib)
- iOS_关联详解
- UVA 12897 Decoding Baby Boos 暴力
- java基础 类与对象 构造器 static
- Chrome的隐身模式
- CentOS7 安装Bind
- java基础第六天
- jackson json 序列化与反序列化时json中字段名称问题
- Linux中的ipmitool工具的使用
- Linux中的ipmitool工具的使用
- Mybatis中namespace的作用
- 高斯模板生成的过程
- 数据运营-如何判断是否要进行数据驱动创新?
- 框架基础学习之--搭建mySSMTest框架总结
- android:showAsAction用法
- springmvc 接收对象 滴灌摘要
- 框架基础学习之--搭建mySSMTest框架总结
- Codeforces Round #309 (Div. 1) B. Kyoya and Permutation 找规律
- android RecyclerView 资源汇总
- iOS 设置程序的图片 以及启动画面