Jan 17

How many files are open ?

Scribbled on Thursday, January 17th, 2008

Most 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.


Enjoyed this post? Subscribe to Full Feeds or by Email and receive free daily updates on this Blog.

No related posts.

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

  1. 1 Trackback(s)

  2. May 15, 2008: How many files are open ? « A Bittersweet Life | blog

Post a Comment

January 2008
M T W T F S S
« Dec   Mar »
 123456
78910111213
14151617181920
21222324252627
28293031