0

Unix/Linux命令行小技巧(17)- 打印进程打开的文件数目

Posted by nanxiao on 一月 13, 2015 in Unix/Linux命令行小技巧专题 |

使用“for p in $(pidof process); do echo "PID # $p has $(lsof -n -a -p $p|wc -l) fd opened."; done”命令打印process进程打开的文件数目。
举个例子:

[root@localhost /]# for p in $(pidof java); do echo "PID # $p has $(lsof -n -a -p $p|wc -l) fd opened."; done
PID # 37747 has 139 fd opened.
PID # 30279 has 117 fd opened.
PID # 28033 has 204 fd opened.
PID # 10501 has 211 fd opened.
PID # 4998 has 442 fd opened.

显示了所有java进程打开的文件数目。
技巧出处:https://twitter.com/nixcraft/status/281010856706334720

 

标签:,

发表评论

电子邮件地址不会被公开。 必填项已用*标注

Copyright © 2013-2017 我的站点 All rights reserved.
This site is using the Desk Mess Mirrored theme, v2.5, from BuyNowShop.com.