“Max open files” for working process

2019-01-11 04:24发布

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

7条回答
Ridiculous、
2楼-- · 2019-01-11 04:32

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 process:

prlimit -n4096 -p pid_of_process

查看更多
Animai°情兽
3楼-- · 2019-01-11 04:33

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

查看更多
唯我独甜
4楼-- · 2019-01-11 04:39

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.

查看更多
淡お忘
5楼-- · 2019-01-11 04:44

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
查看更多
爷、活的狠高调
6楼-- · 2019-01-11 04:47
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.

查看更多
成全新的幸福
7楼-- · 2019-01-11 04:51

The following commands give the max # of open files per process permissible by default limits (soft and hard respectively):

ulimit -Sa
ulimit -Ha

You can use a program or a command to change these limits. Look at ulimit (man ulimit).

查看更多
登录 后发表回答