Linux – Modify ‘Soft Limit’ of ‘Max processes’

linuxprocprocessulimit

I tried ulimit -u 2000 and ulimit -Su 2000 to modify the 'Max processes', and started up my program, but failed. I found file '/proc/pid/limit' is still:

Max processes             1024                 2000                 processes

How could I change the soft limit?

Best Answer

What does ulimit -a show?

You're likely at the global max limit or are encountering a permissions issue. I tried your experiment and it worked just fine for me.

Example

The output of a /proc/pid/limits looks like the following:

$ cat /proc/22666/limits | grep processes
Max processes             1024                 62265                processes 

$ ulimit -a | grep processes
max user processes              (-u) 1024

Setting the soft limit to 2000:

$ ulimit -Su 2000

$ ulimit -a | grep processes
max user processes              (-u) 2000

$ cat /proc/22666/limits | grep processes
Max processes             2000                 62265                processes 

What else?

I'd take a look at your /etc/security/limits.conf file and see if there is a limit coming from that file that's keeping regular users from changing this limit

I'd also look in the directory, /etc/security/limit.d/. There are additional files often times there which include more limits. For example on my Fedora system I have this file:

$ 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     1024

References

Related Question