Linux 中每个进程打开文件的最大数量是多少?

Linux 中每个进程打开文件的最大数量是多少?

我的问题很简单,标题中已经说明了。我的一个应用程序向我抛出“打开文件过多”的错误,尽管应用程序运行时用户的限制高于默认值 1024(lsof -u $USER 报告打开 3000 个文件描述符)。

因为我无法想象为什么会发生这种情况,所以我猜测每个过程可能存在最大值。

任何想法都非常感谢!

编辑:一些可能有帮助的价值观......

root@Debian-60-squeeze-64-minimal ~ # ulimit -n
100000

root@Debian-60-squeeze-64-minimal ~ # tail -n 4 /etc/security/limits.conf 
myapp  soft nofile 100000
myapp  hard nofile 1000000
root soft nofile 100000
root hard nofile 1000000

root@Debian-60-squeeze-64-minimal ~ # lsof -n -u myapp | wc -l
2708

答案1

您可以找到 pid 为的进程的限制,/proc/<pid>/limits并且有一个条目Max open files

答案2

是的,该ulimit工具限制了打开文件的数量和许多其他东西,例如堆栈大小、核心转储大小等。

答案3

您可以在 /etc/systemd/system.conf 中找到每个进程的一些限制

相关内容