LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-05-2015, 07:46 AM   #1
gaurav_s
Member
 
Registered: Jul 2014
Posts: 43

Rep: Reputation: Disabled
Can process pid cross max file open limit?


I am counting current open files by a process pid by :-
cmd1:-
ls /proc/$pid/fd/* | wc -l

and then i am calculating percentage by fetching Max open Files limits.
cmd2:-
cat /proc/pid/limits

Limit Soft Limit Hard Limit Units

Max resident set unlimited unlimited bytes
Max processes 30425 30425 processes
Max open files 4096 4096 files
Max locked memory 65536 65536 bytes


Only pasting part of output.

I am calculating percentage :-

cmd1/cmd2*100

i.e if ls /proc/$pid/fd/* | wc -l gives 1000.
then percentage will be :-
1000/4096*100= approx 25%

sometimes i am getting this percentage as 220 in logs.
scenario is not reproducible now,it happened in some server.

It means process pid is crossing the Max open file limits(4096 ) .
 
Old 06-05-2015, 09:31 AM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
First: /proc/<pid>/fd is only showing file descriptor links to regular files not ALL open "files".
That is to say in UNIX/Linux nearly everything is treated as a "file" not just the regular files for example you might see shared libraries open in memory, sockets (network connections on ports) and devices. To really see every "open file" for a process a much better tool is lsof. If you run "lsof -p <pid>" it will show you everything in use including your file descriptors (typically as CHR entries).

Second: The limits you see are both hard and soft. For root processes the soft limit can be exceeded to hard limit. For other users the ulimit command can be used to set limit for that invocation up to the hard limit but will default to the soft limit otherwise.

Although I've seen many things hit the max open files limit I've never seen anything actually exceed it.
 
Old 06-05-2015, 10:13 AM   #3
gaurav_s
Member
 
Registered: Jul 2014
Posts: 43

Original Poster
Rep: Reputation: Disabled
We were using lsof command earlier ,but lsof command was tawas taking longer time to finish when /mnt/ was down .
so we started using ls /proc/pid/fd.
So, i just want to know whether limit can be crossed when i use ls /proc/pid/fd ?
 
  


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
Too many file open - How can we define Max limit of file descriptor janeshb Linux - Server 11 09-29-2009 11:41 AM
need script to detect log file max limit john89011 Programming 5 03-02-2008 06:42 PM
resources: how to limit process to max. 20% CPU usage alesz Linux - Software 4 03-30-2006 03:49 PM
VFS: file-max limit 25241 reached Toadman Mandriva 1 05-19-2005 11:39 PM
max process limit anoop_chandran Linux - Networking 2 01-16-2002 06:22 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:25 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration