Linux查看系统文件打开数

kelelipeng / 2023-08-30 / 原文

参数配置:

 https://blog.csdn.net/hjh872505574/article/details/129688548

1、查看系统限制用户的最大文件打开数

ulimit -n


2、查看当前打开的文件数
lsof -Ki|wc -l

如果不加参数:lsof |wc -l,统计的是进程的线程数,数据差别还是很大的


查看具体某一个进程打开文件数(需要减1,多了列头)
lsof -p [pid]|wc -l


查看打开文件数最多的6个进程
第一列是数列,第二列是进程id(如上图)

lsof -Ki|awk '{print $2}'|sort|uniq -c|sort -n -r|head -6

 

——————————————————————————————————————————————————————————————————————

 

Too many open files (CLOSE_WAIT过多)的解决方案:修改打开文件数的上限值、调整TCP/IP的参数

 https://blog.51cto.com/iosre/5686484