OK, that seems to work. I still need to figure out how to get the number of file handles for a specific process. The settings in that article provide the load average per cpu.
Main Topics
Browse All TopicsWe have a process that is running out of file handles. We are trying to address this problem with the vendor, but in the meantime we need to bounce it when it is getting near the limit. Currently we use Glance to see how many are in use. Is there some command line way to determine this that we can include into a cron script?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
I found a better answer: If I use lsof -p <PID> it shows all the open files/sockets. I pipe into wc and it tells me the number of open file handles.
Thanks for the suggestions on glance. I think I can use that for other tasks.
tfewster: I will still give you the points for the good direction to research.
Note that you can limit the number of file descriptors that a process can open, using the built-in unix command 'ulimit':
ulimit -n 12 # will limit the number of *available* file descriptors to 12 + 1
If the process attempts to allocate an FD beyond this number, the behaviour is determined by the code itself, or if no provision is made by the code, the process will be issued a HUP or KILL signal, or be coredumped depending on the unix flavour.
The effect being that your process is stopped when it reaches a limit you have set.
The advantage of this method is that you can run a script that sets ulimit, then executes the underlying process in the FOREGROUND, but in a never ending loop. When the process dies, the loop will cycle, and you can do some quick maintenance, and then restart the process. No delays are necessary while you wait for a cron job to kick in.
Note that the semantics of ulimit are slightly different by flavour of unix, so you should test this technique thoroughly.
Actually, the reason I need to monitor is that I have a file handle leak that I cannot fix (in 3rd party code) and I need to be prepared to restart the process when the number available is getting low. The OS kernel is configured for 8000 per process. The process is already under a management system that restarts it, but I prefer to do it gracefully rather than waiting for errors.
Glad to hear you resolved the problem yourself; i suggest you post a (0 point) question in http://www.experts-exchang
http://www.experts-exchang
as the answer and refund your points
Business Accounts
Answer for Membership
by: tfewsterPosted on 2007-05-03 at 11:56:10ID: 19025815
You could run Glance in background and redirect the output to a file, which could then be parsed for the info you need: Mailing-Li sts/HP-UX- Admin/2003 -05/ 0035.h tml matting the data from the output file.
http://unix.derkeiler.com/
The problem would be with selecting/interpreting/for
If you just want to check when the _system_ is running out of file handles, `sar -v` may be good enough for your needs