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

Posted on in Categories Howto, Linux, Linux Scalability, Networking, Troubleshooting, Tuning last updated April 16, 2014

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

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

1 comment

Leave a Comment