Tuesday, September 29, 2009

Increasing open files limit on Linux

Q) How to check open files limit on Linux ?
A) ulimit -a

ulimit Provides control over the resources available to the shell and to processes started by it, on systems that allow such control.
-a All current limits are reported


[testuser@localhost /]$ ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 16303
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 10240
cpu time (seconds, -t) unlimited
max user processes (-u) 1024
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited


Q) How to increase open files limit ?
A) Add the following entries in /etc/security/limits.conf

* soft nofile 8192
* hard nofile 8192

Default limit is 1024 ,You can Increase the limit based on requirement.
In this example I am increasing limit to 8192.

Note that you may need to log out and back in again before the changes take effect.

[testuser@localhost ~]$ ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 16303
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 8192
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 10240
cpu time (seconds, -t) unlimited
max user processes (-u) 1024
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited


You can check only open files limit using 'ulimit -n'.