-1

I have a Java web application set up to start within a script in /etc/init.d/application The application fails with a "too many open files" error but if I execute the same script from my user it won't have any problem.

I already increased the limits in /etc/security/limits.conf but what I don't understand is why this happens only when the machine starts (I tried many times)

Could this be related with the runlevel where the script is executed?

The OS is Redhat 5.4

  • This is impossible to quantify from our side. Keep in mind that open sockets are included in the maximum file handle count. – Andrew B Jul 06 '13 at 00:34

2 Answers2

2

The /etc/security/limits.conf file only affects normal logins. If you want to set the limits on a startup script (which never does any normal login), you have to do it in the script itself.

David Schwartz
  • 31,449
  • 2
  • 55
  • 84
2

To fix, you'll need to execute a command as part of your startup script.

Assuming it's a bash script that then executes your application, add ulimit -n 8192 as a command to it. If it's a java program, use Runtime.getRuntime().exec("ulimit -n 8192") at startup.

Nathan C
  • 15,059
  • 4
  • 43
  • 62