如何将进程的“打开文件”限制从 1024 增加到 10240

Jay*_*yan 3 linux bash

我有一个需要许多临时文件的进程(java 程序)。有一个限制,我们不能有超过 1024 个打开的描述符。如何将进程的“打开文件”限制从 1024 增加到 10240 我可以减少该值......而不是增加它。以下作品。

ulimit -n 899 
Run Code Online (Sandbox Code Playgroud)

以下不起作用

ulimit -n 1025
Run Code Online (Sandbox Code Playgroud)

Thi*_*iro 6

您将需要 root 访问权限来增加它。如果您使用的是 Ubuntu(也适用于其他发行版):http : //ubuntuforums.org/archive/index.php/t-521287.html

如果您使用的是 bash,则命令是“ulimit -n”。要永久更改限制,请编辑 /etc/security/limits.conf (您的发行版可能使用不同的位置)。

要查看所有选项的列表,请使用 -a:

$ ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 20
file size               (blocks, -f) unlimited
pending signals                 (-i) 16382
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) unlimited
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited
Run Code Online (Sandbox Code Playgroud)