Is it possible to increase \"Max open files\" parameter for working process ? I mean this parameter:
cat /proc//limits | grep files
echo -n "Max open files=20:20" > /proc/$pid/limits
...works in RHEL5.5 and RHEL6.7.
Note that the "-n" is mandatory; a trailing newline will generate a complaint about invalid arguments.
Another option is to use the prlimit command (from the util-linux package). For example if you want to set the maximum number of open files for a running process to 4096:
prlimit -n4096 -p pid_of_process
You could use gdb, break into the process, call the aforementioned syscalls to raise the limit you're interested in, then continue the job and exit gdb. I've edited things on the fly this way a few times.
Your app wouldn't be down, but just frozen for the moment while you performed the call. if you're quick (or you script it!), it'll likely not be noticeable.
As a system administrator: The /etc/security/limits.conf file controls this on most Linux installations; it allows you to set per-user limits. You'll want a line like myuser - nofile 1000
.
Within a process: The getrlimit and setrlimit calls control most per-process resource allocation limits. RLIMIT_NOFILE
controls the maximum number of file descriptors. You will need appropriate permissions to call it.
This link details how to change this system wide or per user.
Many application such as Oracle database or Apache web server needs this range quite higher. So you can increase the maximum number of open files by setting a new value in kernel variable /proc/sys/fs/file-max as follows (login as the root):
$ sysctl -w fs.file-max=100000
You need to edit /etc/sysctl.conf file and put following line so that after reboot the setting will remain as it is
Yes, it is possible to increase the limits in /proc/<pid>/limits
at run time. Just find the pid and execute below command:
echo -n "Max open files=20:20" > /proc/$pid/limits