centos7系统执行命令报错-bash: fork: Resource temporarily unavailable

报错代码:-bash: fork: Resource temporarily unavailable

线程太多资源暂时不可用

解决方法:

重启云服务器
使用命令查看系统的进程总数:
ps -ef | wc -l
ps -ef | grep www | wc -l        //查看www用户的进程总数
lsof -u www | wc -l   //显示所属user进程打开的文件
vim /etc/security/limits.d/20-nproc.conf
修改配置 /etc/security/limits.d/90-nproc.conf 增加 www 用户的进程最大限制
增加“ nproc”参数的值 用户或所有用户位于 /etc/security/limits.d/90-nproc.conf
>这是/etc/security/limits.d/90-nproc.conf文件的示例。
<user> - nproc 2048 <<<----[ Only for "<user>" user ]
* - nproc 2048 <<<----[ For all user's ]
应根据要求将nproc值从当前值增加到两倍或三倍。

ulimit -a     //查看最大限制数是否修改成功

reboot   //重启 

示例配置文件内容

[www@vps root]$ cat /etc/security/limits.d/90-nproc.conf
# Default limit for number of user's processes to prevent
# accidental fork bombs.
# See rhbz #432903 for reasoning.

#* soft nproc 102400
root soft nproc unlimited
www soft nproc 102400
* soft nproc 655350
* hard nproc 655350
* soft nofile 655350
* hard nofile 655350

nproc:表示max number of processes
nofile:表示max number of open file descriptors
hard/soft:soft是一个警告值,而hard则是一个真正意义的阀值,超过就会报错。

来源地址https://access.redhat.com/solutions/543503#

posted @ 2020-09-22 15:05  平平无奇网瘾少女  阅读(697)  评论(0)    收藏  举报