On Linux - set maximum open files to unlimited. Possible?

后端 未结 2 422
清酒与你
清酒与你 2021-01-31 20:25

Is it possible to set the maximum number of open files to some \"infinite\" value or must it be a number?

I had a requirement to set the descriptor limit for a daemon us

相关标签:
2条回答
  • 2021-01-31 20:53

    Try the line

    <domain>    -
    

    replacing <domain> with the username, in the simplest case.

    The limits.conf man page says

    -
        for enforcing both soft and hard resource limits together.
    
        Note, if you specify a type of '-' but neglect to supply the
        item and value fields then the module will never enforce any
        limits on the specified user/group etc. .
    
    0 讨论(0)
  • 2021-01-31 20:54

    POSIX allows you to set the RLIMIT_NOFILE resource limit to RLIM_INFINITY using setrlimit(). What this means is that the system will not enforce this resource limit. Of course, you will still be limited by the implementation (e.g. MAXINT) and any other resource limitations (e.g. available memory).

    Update: RHEL 5 has a maximum value of 1048576 (220) for this limit (NR_OPEN in /usr/include/linux/fs.h), and will not accept any larger value including infinity, even for root. So on RHEL 5 you can use this value in /etc/security/limits.conf and that is as close as you are going to get to infinity.

    Not long ago a Linux kernel patch was applied to allow this limit to be set to infinity, however it has since been reverted as a result of unintended consequences.

    0 讨论(0)
提交回复
热议问题