Tuesday, 30 June 2015

Too many open files


If system throws "too many open files" error or something like following during build/compilation
[INFO] java.io.FileNotFoundException: (Too many open files)

This means limit to open files for the user or system has been exceeded.

You can check the limit by running following command

ulimit -a

Solution ->
open file common-session
sudo vi /etc/pam.d/common-session


Add following entry in the file
session required        pam_limits.so

open file limits.conf
sudo vi /etc/security/limits.conf

make sure both soft and hard limits are set to larger number (as per your need)
*                soft    nofile          500240
*                hard    nofile          500240

Logout and login and run command again
ullimit -a

You will see the new limit number.