How many files are open ?
Scribbled on Thursday, January 17th, 2008Most probably to find the answer in Linux, you will type this command at terminal (shell):
lsof | wc -l
lsof will give a row of open files and the result is piped(|) to word count (wc) command that counts the rows/lines (-l)
jit@jit-desktop:~$ lsof | wc -l 5476jit@jit-desktop:~$
So it seems 5476 files are open, but is it really within the max limit of open descriptor for the kernel ?
Lets checkout another way the opened descriptor:
cat /proc/sys/fs/file-nr
jit@jit-desktop:~$ cat /proc/sys/fs/file-nr 5760 0 99842 jit@jit-desktop:~$
So here the first column (5760) is the total allocated file descriptors
0 is the total free allocated file descriptors
99842 is the max file descriptors that can be opened.
There is a difference in the value obtained by lsof and the one retrieved from /proc filesystem.
Explanation:
lsof gives all the opened files whether they are associated with descriptor (a handle to file) or not.
While /proc/sys/fs/file-nr gives the total allocated descriptor count and total free allocated descriptor, last column is maximum descriptor allowed.
PS- The result shown above has confused m…lol, guess i need an explanation. will come back soon with proof.

No related posts.
Related posts brought to you by Yet Another Related Posts Plugin.





1 Trackback(s)