Skip to content

Instantly share code, notes, and snippets.

@girvan
Last active June 21, 2017 06:35
Show Gist options
  • Save girvan/a341513654ad6b1cbb7f365b9f68fa7b to your computer and use it in GitHub Desktop.
Save girvan/a341513654ad6b1cbb7f365b9f68fa7b to your computer and use it in GitHub Desktop.
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
Copy link

xeoncross commented Mar 3, 2017

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