zoukankan      html  css  js  c++  java
  • 解决-bash: fork: retry: Resource temporarily unavailable错误

    上面这段错误提示的本质是Linux操作系统无法创建更多进程,导致出错。
    因此要解决这个问题需要修改Linux允许创建更多的进程。

    修改Linux最大进程数

    我们可以通过ulimit -a来查看当前Linux系统的一些系统参数。

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

      

    在上面这些参数中,通常我们关注得比较多的是一个进程可打开的最大文件数,即open files。
    系统允许创建的最大进程数量即是max user processes 这个参数。
    我们可以使用 ulimit -u 4096 修改max user processes的值,但是只能在当前终端的这个session里面生效,重新登录后仍然是使用系统默认值。
    正确的修改方式是修改/etc/security/limits.d/90-nproc.conf文件中的值。

    # vim /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     4096
      root       soft    nproc     unlimited
    

      

    我们只要修改上面文件中的4096这个值,即可。

  • 相关阅读:
    Codeforces 1265A Beautiful String
    1039 Course List for Student (25)
    1038 Recover the Smallest Number (30)
    1037 Magic Coupon (25)
    1024 Palindromic Number (25)
    1051 Pop Sequence (25)
    1019 General Palindromic Number (20)
    1031 Hello World for U (20)
    1012 The Best Rank (25)
    1011 World Cup Betting (20)
  • 原文地址:https://www.cnblogs.com/Gnnnny/p/10154496.html
Copyright © 2011-2022 走看看