Linux Increase Process Identifiers Limit with /proc/sys/kernel/pid_max

last updated in Categories Howto, Linux, Linux Scalability, Networking, Troubleshooting, Tuning

Yesterday I wrote about increasing local port range with net.ipv4.ip_local_port_range proc file. There is also /proc/sys/kernel/pid_max file, which specifies the value at which PIDs wrap around (i.e., the value in this file is one greater than the maximum PID). The default value for this file, 32768, results in the same range of PIDs as on earlier kernels (<=2.4). The value in this file can be set to any value up to 2^22 (PID_MAX_LIMIT, approximately 4 million).
Increasing the value will help on large Linux system or clusters to ease process identification and process management. You can easily prevent fork() failures error message with this hack.


Display Current Process Identifiers Limit On a Linux Based Systems

Type the following command at shell prompt:
$ sysctl kernel.pid_max
$ cat /proc/sys/kernel/pid_max
$ sysctl kernel.pid_max
Sample outputs:

kernel.pid_max = 32768

Allow for more PIDs on a Linux based systems

Type the following command:
# sysctl -w kernel.pid_max=4194303
# echo 4194303 > /proc/sys/kernel/pid_max

You need to append the following config directive to your /etc/sysctl.conf file:
kernel.pid_max = 4194303

Please note that this hack is only useful for a large and busy server; don’t try this on an old kernel or on desktop systems.

See also
  • Man pages – sysctl(8),proc(5)

# Additional correction by Mæja Stefansson; Editing by VG – log #

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.


1 comment

Leave a Comment