Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a big problem and that is that my company's production application which I unfortunately can't shutdown and restart ( I am unsure how, and I don't want to do any mistake) is spitting out a lot of exceptions on too many files open when trying to open a socket to read from an ftp server.

2013-01-02 16:19:03,222 ERROR [main] software.background.Program(Program.java:doExecute{225}) - Exception during ftp transfer
someclasses.ftp.FtpException: Could not create connection to xxxx
    at someclasses.communication.ftp.FtpImpl.connect(FtpImpl.java:114)
    at Program.doExecute(Program.java:176)
    at Program.main(Program.java:287)
Caused by: java.net.SocketException: Too many open files
    at java.net.Socket.createImpl(Socket.java:397)
    at java.net.Socket.<init>(Socket.java:371)
    at java.net.Socket.<init>(Socket.java:189)
    at someclasses.Ftp.connect(Ftp.java:386)

I understand that the per application limit of open files / sockets and so on is reached. Is there any way to increase this maximum for the time being without closing the application? I have run the command ulimit and it states unlimited. I've tried to check how many connections it has open with the lsof -p PID command but it states "command not found".

Would be very glad if someone could help me find another similar effect that lsof has (I think it's a red hat machine) and advice for how to fix this temporary? The most pleasant solution to this would be to increase the files / sockets the application could open. This is just a plain java application.

Thanks in advance!

EDIT another solution would be if there were any command where I could look up how this program was run from the beginning with all the eventual flags. Then I maybe could restart it with success. This is a legacy app.

share|improve this question

migrated from stackoverflow.com Jan 2 '13 at 20:02

This question came from our site for professional and enthusiast programmers.

    
to look up the full command lines for running apps use "ps -FA" – Steve Perkson Jan 2 '13 at 15:55
    
Thanks for the comment, I will probably use this if changing the ulimit -n to 2048 instead of 1024 won't fix it. lj4newbies.blogspot.se/2007/04/too-many-open-files.html changed it to the nofile configuration displayed in the link. You think it'll work? – cubsink Jan 2 '13 at 16:03
1  
Running out of file descriptor also could be hint that your app is leaking file descriptors: missing to close them if not used anymore. If this is the case, increasing the number of available file descriptors won't help in the long. – alk Jan 2 '13 at 16:11
    
can you check /proc/sys/fs/file-max – JoG Jan 2 '13 at 16:27
    
@JoG That is a system maximum. – Peter Lawrey Jan 2 '13 at 16:29
up vote 1 down vote accepted

It all ended with a restart of the application. I changed the ulimit -n to 2048 and reloaded the config. However, all processes inherited the old config and the application had to be restarted.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .