"Max open files" for working process

Viewed 93260

Is it possible to increase "Max open files" parameter for working process ? I mean this parameter:

cat /proc/<pid>/limits | grep files

Thanks for your advices

8 Answers

On Ubuntu 16.04, with a rethinkdb process running, none of these solutions worked.

I kept getting error: accept() failed: Too many open files.

What ultimately worked was this in my /etc/security/limits.conf file. Note the nproc in addition to the nofile. As I understand it, root needs to specified separately.

*                soft    nofile          200000
*                hard    nofile          1048576
root             soft    nofile          200000
root             hard    nofile          1048576
*                soft    nproc           200000
*                hard    nproc           1048576
root             soft    nproc           200000
root             hard    nproc           1048576

You can see the system max files by running cat /proc/sys/fs/file-max. I just set mine to a high maximum well within reason for the size of the server.

You can verify the max open files your process is allowed by running cat /proc/{your-pid}/limits.

Helpful post: https://medium.com/@muhammadtriwibowo/set-permanently-ulimit-n-open-files-in-ubuntu-4d61064429a

Related