I plan to run a Java app using
nohup ... &. The limit must apply to commands like this.
Most systems use PAM, and have the
pam_limits module set limits based on
/etc/security/limits.conf. The per-user limit for open files is called
nofile. You can set it for every user or for a particular user or group, and you can set a limit that the user can override (soft limit) and another that only root can override (hard limit). The documentation and the
limits.conf man page have the details. For example, to raise the limit to 50000 for everyone, put this line in
/etc/limits.conf (the setting takes effect when you log in):
* - nofile 50000
You can use ulimit for this:
Although you should make sure that opening so many file handles is absolutely necessary before resorting to such adjustments. Increasing the maximum file handles just because you have forgotten to do an inputstream.close() in a loop is only going to delay the underlying problem.