When running my application I sometimes get an error about "too many files open". Running "ulimit -a" reports that the limit is 1024. How do I increase the limit above 1024?
Edit "ulimit -n 2048" results in a permission error.
When running my application I sometimes get an error about "too many files open". Running "ulimit -a" reports that the limit is 1024. How do I increase the limit above 1024?
Edit "ulimit -n 2048" results in a permission error.
You could always try doing a ulimit -n 2048
. This will only reset the limit for your current shell and the number you specify must not exceed the hard limit
Each operating system has a different hard limit setup in a configuration file. For instance, the hard open file limit on Solaris can be set on boot from /etc/system.
set rlim_fd_max = 166384
set rlim_fd_cur = 8192
On OS X, this same data must be set in /etc/sysctl.conf.
kern.maxfilesperproc=166384
kern.maxfiles=8192
Under Linux, these settings are often in /etc/limits.conf.
Hard limits are maintained by the kernel while the soft limits are enforced by the shell. By definition, the shell limit can not exceed the kernel limit. Even the root user can not reset the system limits without modifying the config file and rebooting the machine.
In addition to the hard limits, there are often defaults set when the machine boots. So, even though you may reset your ulimit in an individual shell, you may find that it resets back to the previous value on reboot. You may want to grep your boot scripts for the existence ulimit commands if you want to change the default.
If you are using Linux and you got the permission error, you will need to raise the allowed limit in the /etc/limits.conf or /etc/security/limits.conf file (where the file is located depends on your specific Linux distribution).
For example to allow anyone on the machine to raise their number of open files up to 10000 add the line to the limits.conf file.
* hard nofile 10000
Then logout and relogin to your system and you should be able to do:
ulimit -n 10000
without a permission error.