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 (
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
- Man pages – proc(5)
# Additional correction by Mæja Stefansson; Editing by VG – log #
🐧 Get the latest tutorials on Linux, Open Source & DevOps via:
- RSS feed or Weekly email newsletter
- Share on Twitter • Facebook • 1 comment... add one ↓
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
Why is this not default?
On a non-busy system what penalty do you pay by raising the limit to the max?