How do I determine whether the number of open files is exceeding the limit set in the kernel?
Posted by lopeza on December 2, 2008
First place I thought of looking is lsof, but quickly I realized that the result may not be accurate.
# lsof -n | wc -l 3233 |
A better way to find the value would be to use
# cat /proc/sys/fs/file-nr | awk '{print $1-$2}'
3060
|
If you wanted to list and change your values
# cat /proc/sys/fs/file-max 767479 # echo "104854" > /proc/sys/fs/file-max |
# cat /proc/sys/fs/file-nr 2550 0 767479 | | | | | | | | maximum open file descriptors | total free allocated file descriptors total allocated file descriptors (the number of file descriptors allocated since boot) |
The number of open file descriptors is column 1 – column 2; (Note: we have read contradictory definitions of the second column in newsgroups. Some people say it is the number of used allocated file descriptors – just the opposite of what we’ve stated here. Luckily, we can prove that the second number is free descriptors. Just launch an xterm or any new process and watch the second number go down.)