http://www.perlmonks.org?node_id=711822


in reply to Re^2: How to debug "Too Many Open Files" Error
in thread How to debug "Too Many Open Files" Error

Is there any way I can run the command you show from inside my script? If not, I can ask my hosting service to run it. Needless to say, they do not invite me to run commands directly on their server.

It's important that this command be run by your script a short time before it crashes. Otherwise the output might not be helpful.

As you have not posted code, I assume that you don't know where the error happens. This makes it difficult to run the command shortly before that, so I suggest putting something like

warn `ls -l /proc/$$/fd/` . ' ';

in various places in your code; you will probably see the output in your server log.

The appended whitespace ' ' ensures that the string does not end in a newline. warn() and die() append the source code line number in that case.