Post

linux configure ulimit

linux configure ulimit

Java applications in production frequently hit the default file descriptor limits, causing cryptic ‘too many open files’ errors. The fix is setting higher limits in /etc/security/limits.conf for the user running the JVM. This is a day-one config for any serious Java deployment on Linux.

  • Create file called limits.conf
1
$ touch limits.conf
  • Add limits configuration to the limits.conf

Assuming user that you want to increase limits for is called ‘java’

1
2
$ echo "java soft nofile 8196" > limits.conf
$ echo "java hard nofile 65536" >> limits.conf
  • Move file to /etc/security
1
$ sudo mv limits.conf /etc/security
  • if file already exists in /etc/security

Then directly append contents to the file

1
2
$ sudo echo "java soft nofile 8196" >> limits.conf
$ sudo echo "java hard nofile 65536" >> limits.conf
  • Verify that limits have been applied correctly
1
2
3
4
5
$ ulimit -Hn
unlimited

$ ulimit -Sn
8196
This post is licensed under CC BY 4.0 by the author.