标签 文件打开数量 下的文章

先获取到该进程号,然后执行:

ls -l /proc/xxx/fd

xxx为具体的进程号,输出例入下:

total 0
lr-x------ 1 namer namer 64 Jul 14 21:41 0 -> pipe:[271495439]
l-wx------ 1 namer namer 64 Jul 14 21:41 1 -> pipe:[271495440]
lr-x------ 1 namer namer 64 Jul 14 21:41 10 -> anon_inode:inotify
lrwx------ 1 namer namer 64 Jul 18 07:00 11 -> socket:[274231623]
l-wx------ 1 namer namer 64 Jul 16 17:27 12 -> /workspace/door-god/log/2017-07-18.log
l-wx------ 1 namer namer 64 Jul 17 23:05 13 -> /workspace/door-god/log/2017-07-18.log
lrwx------ 1 namer namer 64 Jul 18 11:30 14 -> socket:[274230820]
lrwx------ 1 namer namer 64 Jul 18 15:16 15 -> socket:[274234729]
lr-x------ 1 namer namer 64 Jul 16 07:36 16 -> /dev/urandom
l-wx------ 1 namer namer 64 Jul 14 21:41 2 -> pipe:[271495441]
lrwx------ 1 namer namer 64 Jul 14 21:41 3 -> socket:[274235127]
lrwx------ 1 namer namer 64 Jul 14 21:41 4 -> socket:[271495456]
lr-x------ 1 namer namer 64 Jul 14 21:41 5 -> anon_inode:inotify
lr-x------ 1 namer namer 64 Jul 14 21:41 7 -> anon_inode:inotify
lrwx------ 1 namer namer 64 Jul 14 21:41 8 -> anon_inode:[eventpoll]
lrwx------ 1 namer namer 64 Jul 14 21:41 9 -> socket:[271495458]

则为打开的文件数量,如果要快速获取文件数量,则可以:

ls -l /proc/xxx/fd|wc -l