Monday, May 2, 2011

Error: Too many open files

Couple days ago, I ran into this error on CentOS 5.2.  To my understanding this error can occur on all flavors of linux.

This totally caught me by surprise as I had never seen this before.  I had just finished installing awstats and wanted to run an update for the first time.  The logs were gathered from 6 webservers and each webserver had about 225 logs.
The awstats log merging script tried to open these log files (225×6 = 1,350 logs) and merge them to read the data but it kept crashing.  The reason it kept crashing was because the limit for the maximum number of files that you are allowed to open in a shell was set to 1024.

To check what your limits are just type in the following command:
 
ulimit -a
 
To change the limit for the number of files you are allowed to open, change the “open files” limit.  To do so, type in the following command:
 
ulimit -n3000
 
This will set the limit to 3000 files.  You can set it to whatever number you need to.
After changing my “open files” limit, I was able to run my initial awstats update without any issues.

No comments:

Post a Comment

Error: Too many open files

Couple days ago, I ran into this error on CentOS 5.2.  To my understanding this error can occur on all flavors of l...