Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
if grep -q 32768 /etc/security/limits.conf; then
echo skip /etc/security/limits.conf;
else
echo "* hard nofile 32768" | sudo tee -a /etc/security/limits.conf
echo "* soft nofile 32768" | sudo tee -a /etc/security/limits.conf
echo "root hard nofile 65536" | sudo tee -a /etc/security/limits.conf
echo "root soft nofile 65536" | sudo tee -a /etc/security/limits.conf
fi
if grep -q net.core.somaxconn /etc/sysctl.conf; then
echo skip /etc/sysctl.conf;
else
echo "net.core.somaxconn = 65536" | sudo tee -a /etc/sysctl.conf
fi
echo "reload settings";
sudo sysctl -p

Xeoncross commented Mar 3, 2017 edited

Verify the new ulimit / files open settings

cat /proc/sys/fs/file-max && ulimit -n && ulimit -Hn

It's worth noting that ubuntu 16.04+ now has much higher defaults

815927
1024
65536

So you only need a single line for the soft limits

    echo "*         soft    nofile      32768" | sudo tee -a /etc/security/limits.conf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment