LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices

Reply
 
Search this Thread
Old 12-20-2006, 12:42 PM   #1
closet geek
Member
 
Registered: Apr 2003
Location: England
Posts: 146

Rep: Reputation: 15
Find out the number of files currently opened


I know where to see the maximum number of files that are allowed to be open, I know how to set this value also (thanks to ulimit) but where can I see the current number of opened files?

cg
 
Old 12-20-2006, 12:46 PM   #2
hiren_bhatt
Member
 
Registered: Oct 2005
Distribution: FC3,Debian
Posts: 127

Rep: Reputation: 15
Use lsof. See the man pages for more details
 
Old 12-20-2006, 12:57 PM   #3
closet geek
Member
 
Registered: Apr 2003
Location: England
Posts: 146

Original Poster
Rep: Reputation: 15
Well, lsof | wc -l seems to do. That outputs 39537, however ulimit -a says only 4096 files are allowed to be opened at a time. Yet /proc/sys/fs/file-max gives 131072 file desriptors allowed and apparently the system in question here is only using 11920. Yet Apache still gives:

"host: isc_socket_create: not enough free resources"

which I'm reliably informed is a problem with the number of files opened. Anyone care to clarify this for me! Perhaps there is a way to find out the number of files opened in a ulimit compatiable way (or in other ways, in a way that ulimit would care about and use to determine if too many are open?).

Thanks,

cg

p.s. is ulimit per-process limits?

Last edited by closet geek; 12-20-2006 at 01:01 PM.
 
Old 12-21-2006, 01:20 PM   #4
closet geek
Member
 
Registered: Apr 2003
Location: England
Posts: 146

Original Poster
Rep: Reputation: 15
Help?

cg
 
Old 12-22-2006, 01:45 PM   #5
hiren_bhatt
Member
 
Registered: Oct 2005
Distribution: FC3,Debian
Posts: 127

Rep: Reputation: 15
Quote:
Originally Posted by closet geek
Well, lsof | wc -l seems to do. That outputs 39537, however ulimit -a says only 4096 files are allowed to be opened at a time. Yet /proc/sys/fs/file-max gives 131072 file desriptors allowed and apparently the system in question here is only using 11920.
p.s. is ulimit per-process limits?
Yes ulimit is a per process limit and you can increase or decrease it. Also the /proc/sys/fs/file-max tells the maximum open file descriptors allowed by the kernel.

Ok now if you see /proc/sys/fs/file-nr, the first column show number of current open file descriptors and the third column show the total allowed file descriptors which is equal to /proc/sys/fs/file-max. But lsof | wc -l will show you more number then that in the first column, that is because lsof will also list files without a file discreptor(e.g. you may see a lot of memory maped library files). To check this try lsof | wc -l | grep 4893 (where 4893 is pid of some process just taken for example), now check for the same pid in /proc/4893/fd. You will see the difference. Also if you want, you can set the /proc/sys/fs/file-max as follows.
e.g. echo "12227" > /proc/sys/fs/file-max.
I think it is much clear now.

Quote:
Originally Posted by closet geek
Yet Apache still gives:

"host: isc_socket_create: not enough free resources"

which I'm reliably informed is a problem with the number of files opened.
Not very much sure about the above question but maybe it is because the per-process limit is 4096, which may be less for Apache. Increasing this limit should help you.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to find the total number of files in a folder cnm Linux - Newbie 17 09-21-2013 06:33 AM
Mandrake 10.x - Gvim 'split open' corrupts opened files and leaves ghost swapfiles Xolo Linux - Software 0 05-23-2005 05:24 AM
How to find out an error number orlenok Linux - Newbie 2 10-05-2003 11:47 AM
how do u find AS Number of an IP address? knight_ridda Linux - Networking 4 02-28-2003 01:16 PM
How to find out the port number fmohideen76 Linux - General 3 07-11-2002 08:18 AM


All times are GMT -5. The time now is 07:26 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration