Ubuntu Troubleshooting
Error: Too many open files in system
Unable to get a directory listing or execute some commands. Console returns error message containing the text "Too many open files in system."
Everything in Linux are files; Linux forks most things including devices, sockets and pipes as files. There is a kernel parameter called “file-max” which controls the maximum number of files that can be opened in a system. The default value is 65K (approx), can be find using the following command:
sysctl -a | grep file-max
To check the count of number of files open, we can use the following command:
lsof | wc –l
To prevent Ubuntu from running out of filehandles you need to make sure that there are enough file handles available at the system level, and that the user you are running Ubuntu as is allowed to use enough file handles:
Run the command sysctl -a. If this is less than 200000, increase the number of file handles by editing /etc/sysctl.conf and changing the property fs.file-max to 200000. If there isn't a value set already for this property, you need to add the line fs.file-max=200000.
vi /etc/sysctl.conf
add to file:
fs.file-max=200000
save and execute the command:
sysctl -p