Skip to content

Instantly share code, notes, and snippets.

@dotcomputercraft
Created November 5, 2015 15:24
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save dotcomputercraft/0947eb7ed6b3b5cc14b6 to your computer and use it in GitHub Desktop.
Save dotcomputercraft/0947eb7ed6b3b5cc14b6 to your computer and use it in GitHub Desktop.
increase max number of ulimit open file and max user processes in Linux.
1- Step : open the sysctl.conf and add this line fs.file-max = 65536
vi /etc/sysctl.conf add end of line
fs.file-max=500000
save and exit.
2. Step : vi /etc/security/limits.conf and add below the mentioned
* soft nproc 500000
* hard nproc 500000
* hard nofile 500000
* soft nofile 500000
root hard nofile 500000
root soft nofile 500000
jetadmin hard nofile 500000
jetadmin soft nofile 500000
nginx hard nofile 500000
nginx soft nofile 500000
and vi /etc/security/limits.d/90-nproc.conf
* soft nproc 500000
* hard nproc 500000
* soft nofile 500000
* hard nofile 500000
save and exit
3. Step - pam-limits
vi /etc/pam.d/common-session
Add following line at the end of the file:
session required pam_limits.so
save and exit
4. Reboot ubuntu server
@meramsey
Copy link

Nice reference can do this by appending to the end of the file too in scripted manner :)

#!/usr/bin/env bash
# References: https://gist.github.com/dotcomputercraft/0947eb7ed6b3b5cc14b6

echo "Increasing open files limit per user /etc/security/limits.conf"
cat >> /etc/security/limits.conf <<EOL
*         soft    nproc       500000
*         hard    nproc       500000
*         hard    nofile      500000
*         soft    nofile      500000
root      hard    nofile      500000
root      soft    nofile      500000
EOL

echo "Increasing open files limit per user /etc/security/limits.d/90-nproc.conf"
cat >> /etc/security/limits.d/90-nproc.conf <<EOL
*          soft     nproc          500000
*          hard     nproc          500000
*          soft     nofile         500000
*          hard     nofile         500000
EOL

echo "Raising System-Wide Limit open files /etc/sysctl.conf"
cat >> /etc/sysctl.conf <<EOL
fs.file-max = 2097152
EOL
sysctl -p

echo "Raising pam-limits /etc/pam.d/common-session"
cat >> /etc/pam.d/common-session <<EOL
session required pam_limits.so
EOL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment