如何在linux中更改每个用户的默认最大进程数
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19513986/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to change default number of max process per user in linux
提问by Malintha
I have faced a problem with the changing the default number of processes for user in linux. I have tried to edit /etc/security/limits.conffile with adding the following line.
我在更改 linux 中用户的默认进程数时遇到了问题。我试图通过添加以下行来编辑/etc/security/limits.conf文件。
malintha hard nproc 10000
After I saving it I tried following command on terminal
保存后,我尝试在终端上执行以下命令
ulimit -u
and it give the previous value (1024) , But not the updated value. How can I fix this permanently ?
它给出了先前的值 (1024) ,但不是更新后的值。我怎样才能永久解决这个问题?
this is my limits.conf file
这是我的limits.conf文件
回答by omegahost
Editing the file requires a server reboot, you can use a simpler way:
编辑文件需要重启服务器,您可以使用更简单的方法:
chuser nofiles=10000 malintha
disconnect from you console and reconnect again using the username malintha
. Use ulimit -n
and the output should now be 10000
.
断开与控制台的连接,然后使用 username 重新连接malintha
。使用ulimit -n
,输出现在应该是10000
.
回答by rogerdpack
The problem here is that you specify "hard" in
这里的问题是你在
malintha hard nproc 10000
马林莎硬 nproc 10000
hard is the "max" limit, and soft is the default. So you can leave it as hard and then use ulimit -u 1000
and processes after that point, for that bash shell, will have the increased limit, or use soft, then it will be the default for all processes started by your user [remember to logout and re-login with each change].
hard 是“最大”限制,soft 是默认值。因此,您可以将其保留为硬,然后ulimit -u 1000
在该点之后使用和处理,对于该 bash shell,将增加限制,或使用软,然后它将成为您的用户启动的所有进程的默认值 [记得注销并重新- 每次更改时登录]。
For those looking to try and figure out why they are limited to [for instance] 1024 max theads for a given user, also note that it reads the /etc/security/limits.conf file and other /etc/security/limits.d/* files.
对于那些想尝试弄清楚为什么给定用户限制为 [例如] 1024 个最大 theads 的人,还要注意它读取 /etc/security/limits.conf 文件和其他 /etc/security/limits.d /* 文件。