fork: retry: Resource temporarily unavailable
我正在调查是哪个进程导致了这个问题,并且想知道这个机制是如何工作的。
#!/bin/bash
#test.sh
for i in `seq 1 13000`; do
echo $i
sleep 60&
done
在我运行这个脚本(./test.sh)之后,消息如下所示。
...
12265
12266
12267
12268
./test.sh: fork: retry: Resource temporarily unavailable
./test.sh: fork: retry: Resource temporarily unavailable
./test.sh: fork: retry: Resource temporarily unavailable
./test.sh: fork: retry: Resource temporarily unavailable
./test.sh: fork: Resource temporarily unavailable
ps -elf |wc
大约是 133xx 行。 ulimit -u
为 1030977。
fork: retry: Resource temporary unavailable
是否显示由于进程数达到 1030977?如果为真,我如何知道当前计数以及如何知道哪个进程 fork 了大多数进程?
最佳答案
在/etc/security/limits.conf 中为用户或所有用户增加“nproc”参数的值
示例:
@student hard nproc 2048
检查:nproc 值可以根据需要增加。 这里的模板是:
<domain> <type> <item> <value>
"@student" -- Replace it with user for which limit has to be applied. For root user, username is "root"
"hard" for enforcing hard limits
"nproc" for max number of processes
Last column is value.
要查找哪个进程正在派生最多的进程,请使用命令“pstree”。为了确定计数,请使用以下方法。
$ps | gawk '{count[$NF]++}END{for(j in count) print ""count[j]":",j}'|sort -rn|head -n 5
示例:
#ps | gawk '{count[$NF]++}END{for(j in count) print ""count[j]":",j}'|sort -rn|head -n 5
3: bash
1: sudo
1: sort
1: ps
1: CMD
关于linux - 如何知道当前进程数以及哪个进程派生了最多进程?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50753061/