Linux进程运行了很久,怎么能够得到某一进程所有的线程个数并且得到它们的启动时间,除了读取/proc信息之外,我们可以使用ps简单的达到目的。
ps max -o lstart,lwp,pid,nlwp,cmd
lstart STARTED time the command started.
nlwp NLWP number of lwps (threads) in the process. (alias thcount).
lwp LWP lwp (light weight process, or thread) ID of the lwp being reported. (alias spid, tid).
root@ubuntu:~# ps max -o %mem,lstart,lwp,pid,nlwp,cmd
7.9 Sat Sep 15 21:34:41 2012 - 14295 9 /home/sina/Downloads/qemu-kvm-1.1
- Sat Sep 15 21:34:41 2012 14295 - - -
- Sat Sep 15 21:34:41 2012 14297 - - -
- Sat Sep 15 21:34:41 2012 14298 - - -
- Sat Sep 15 21:34:41 2012 14299 - - -
- Sat Sep 15 21:34:41 2012 14300 - - -
- Sat Sep 15 21:34:41 2012 14301 - - -
- Sat Sep 15 21:34:41 2012 14302 - - -
- Sat Sep 15 21:34:41 2012 14303 - - -
- Sat Sep 15 21:34:41 2012 14304 - - -
0.0 Sat Sep 15 21:34:41 2012 - 14305 1 [kvm-pit-wq]
- Sat Sep 15 21:34:41 2012 14305 - - -
0.2 Sat Sep 15 21:37:17 2012 - 14370 1 bash
- Sat Sep 15 21:37:17 2012 14370 - - -
0.0 Sat Sep 15 21:38:33 2012 - 14440 1 [kworker/3:1]
- Sat Sep 15 21:38:33 2012 14440 - - -
root@ubuntu:~# ls /proc/14295/task/
14295 14297 14298 14299 14300 14301 14302 14303 14304
原文链接:
http://blog.csdn.net/licanhua/article/details/6960543