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

by on November 3, 2007 · 1 comment· LAST UPDATED April 16, 2014

in , ,

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
OR
$ cat /proc/sys/kernel/pid_max
OR
$ 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
OR
# 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 #

TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 1 comment… read it below or add one }

1 Ole Tange August 25, 2014 at 9:07 am

Why is this not default?

On a non-busy system what penalty do you pay by raising the limit to the max?

Reply

Leave a Comment

Tagged as: , , , , ,

Previous post:

Next post: