Linux - File descriptors exhausted, how to recover
I am logged in as "root" and after a while my CentOS box runs out of file descriptors. How do I find out who (user/process) is polluting my server and how to get the server back without rebooting? I am on a bash shell.
|
Quote:
A brief Google search turns up lots about increasing your file descriptors: https://www.centos.org/modules/newbb...&viewmode=flat http://prefetch.net/blog/index.php/2...linux-servers/ but that only addresses the initial problem, and doesn't identify the root cause. Unless you provide details, we can't help. |
CentOS 5.5. 64-bit. 4-5 users. It is a test box and guys just run test code. I use a bash shell.
So one of the guys runs a script which creates a lot of files and keeps them open so that the system runs out of file-descriptors. I am on another shell, still logged in as root. How can I recover the system? |
If he's opening too many files (and the default settings are pretty high, so it shouldn't be a problem or he's doing something odd/wrong), then he needs to close them or you can kill some of his processes, which will have the same effect.
Don't mess with the system settings; that's addressing the symptom(s), not the root cause. |
That is what my question is... how? All the file descriptors are exhausted by the system. You cannot run any commands (kill, lsof, ls, ps, cat, etc.) except the inbuilt shell commands. I first need to find out the offending user, the processes and then take action... since I can't run most of the commands, how to go about it?
|
Taking this quote literally as accurate
Quote:
HOWEVER, you might want to wait to see if one of the Mods has a better answer. I can't think of a built-in cmd that would do what you need without using a file descriptor. Why don't you ask your users, maybe the offender will know of a way of signalling his/her procs to die? |
Quote:
If some process is not closing their file descriptor properly, in the above directory you'll see a hell lot of fds! |
Quote:
Quote:
Quote:
|
Quote:
Let us know if you are able to run . df -i command. Here you may find 100% inode in suspected partition. I used find command to remove 20 days older file. Quote:
In my system it was .txt so I used the command. (beware: extention of file must be unique with file otherwise do not take risk. use starting name of file) for eg. Quote:
|
If you have busybox on your system, you could try using it as your shell. That might let you run (some) commands without needing additional descriptors.
You might find this tuning tip interesting. |
@sharadchhetri: inodes != file descriptors..
He basically can't run any cmds because all the useful ones require one or more file descriptors to be opened... |
Quote:
"So one of the guys runs a script which creates a lot of files and keeps them open so that the system runs out of file-descriptors. I am on another shell, still logged in as root. How can I recover the system?" Shibu, are you only not able to run ls command in that directory or ls command in all directory? |
@sharadchhetri - No, 'ls' won't run.
|
The only commands that have any chance of running are the shell builtins, and any of those that need to access a file or directory won't work either. If the PID of the offending process were known, you could use the kill command (a shell builtin) to terminate the process, but I don't know of any way to find that PID without being able to access /proc, and you'd need a file descriptor to do that.
|
Perhaps the OPs problem is as simple as changing the ulimit -n value for his shell (if his distribution permits it). From the manual page:
Code:
ulimit [-HSTabcdefilmnpqrstuvx [limit]] |
All times are GMT -5. The time now is 02:50 AM. |