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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
06-05-2015, 07:46 AM
|
#1
|
Member
Registered: Jul 2014
Posts: 43
Rep:
|
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 ) .
|
|
|
06-05-2015, 09:31 AM
|
#2
|
LQ Guru
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
|
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.
|
|
|
06-05-2015, 10:13 AM
|
#3
|
Member
Registered: Jul 2014
Posts: 43
Original Poster
Rep:
|
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 ?
|
|
|
All times are GMT -5. The time now is 02:25 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|