1

我完全被 Linux 中打开文件描述符的限制弄糊涂了。

他们哪个值是正确的?

ulimit -n======> 65535

vim /etc/security/limits.conf

  • 软文件 50000
  • 硬文件 90000
4

3 回答 3

4

The limits applied in /etc/security/limits.conf are applied by the limits authentication module at login if it's part of the PAM configuration. Then the shell gets invoked which can apply it's own limits to the shell.

If you're asking which one is in effect, then it's the result from the ulimit call. if it's not invoked with the -H option, then it displays the soft limit.

The idea behind the limits.conf settings is to have a global place to apply limits for, for example, remote logins

于 2012-05-18T07:50:03.683 回答
2

Limits for things like file descriptors can be set at the user level, or on a system wide level. /etc/security/limits.conf is where you can set user level limits, which might be different limits for each user, or just defaults that apply to all users. The example you show has a soft (~warning) level limit of 50000, but a hard (absolute maximum) limit of 90000.

However, a system limit of 65535 might be in place, which would take precedence over the user limit. I think system limits are set in /etc/sysctl.conf, if my memory serves correctly. You might check there to see if you're being limited by the system.

Also, the ulimit command can take switches to specifically show the soft (-Sn) and hard (-Hn) limits for file descriptors.

于 2012-05-18T07:49:50.557 回答
0

我认为这个conf被系统中的所有应用程序使用。如果您确实想更改一个特定的应用程序,您可以尝试 setrlimit() 或 getrlimt()。man doc 剂量解释了一切。

于 2012-05-18T11:29:50.040 回答