Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I plan to run a Java app using nohup ... &. The limit must apply to commands like this.

share|improve this question

migrated from stackoverflow.com Apr 5 '11 at 8:28

This question came from our site for professional and enthusiast programmers.

    
Not programming-related - belongs on serverfault ? –  Paul R Mar 8 '10 at 8:48
    
But this caused an error in my java program –  bruce dou Mar 8 '10 at 8:53

6 Answers 6

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
share|improve this answer

you can add fs.file-max = <your number> into /etc/sysctl.conf. Then reboot.

share|improve this answer
    
cat /proc/sys/fs/file-max is 169203,but ulimit -n is 1024 –  bruce dou Mar 8 '10 at 8:51
    
No need to reboot. Just run sysctl fs.file-max=123456. (/etc/sysctl.conf is read at boot time by a script that calls sysctl on the contents.) –  Gilles Apr 5 '11 at 21:06
ulimit -n

can modify per process settings and

/proc/sys/fs/file-max

or the sysctl variable called fs.file-max can be used to read and set the system-wide value

share|improve this answer
    
cat /proc/sys/fs/file-max is 169203,but ulimit -n is 1024 –  bruce dou Mar 8 '10 at 8:47

You can use ulimit for this:

http://bloggerdigest.blogspot.com/2006/10/purpose-of-ulimit-linux-command.html

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.

share|improve this answer
1  
I want to connect to lots of clients –  bruce dou Mar 8 '10 at 8:52

vi ~/.bashrc And add a line at the end of file

ulimit -n 169203
share|improve this answer

Use ulimit(Bash command - man bash or find similar for your shell) per program instance. Do not use global system limits if you don't know what are you doing - possible DoS.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.