By Keith Mitnick on Tuesday, 29 November 2016
Category: General

Maximum Number of Open Files Error on OS X

I viewed the system log files and saw the following error message every two minutes:

Nov 11 11:27:34 hcstest smbd[416]: in openpam_read_chain(): /etc/pam.d/other: Too many open files
Nov 11 11:27:34 hcstest smbd[416]: in openpam_read_chain(): /etc/pam.conf: Too many open files


I ran the “ulimit -a” command to see what the default open file size and Max user processes size were.  They were 256 and 709 which is very low.

ulimit -a 

core file size          (blocks, -c) 0  
data seg size           (kbytes, -d) unlimited  
file size               (blocks, -f) unlimited  
max locked memory       (kbytes, -l) unlimited  
max memory size         (kbytes, -m) unlimited  
open files                      (-n) 256  
pipe size            (512 bytes, -p) 1  
stack size              (kbytes, -s) 8192  
cpu time               (seconds, -t) unlimited  
max user processes              (-u) 709  
virtual memory          (kbytes, -v) unlimited  

I created two plist files that will change the default open file size and max user processes size limits to 524288 and 2048 and and put them in the following location:

/Library/LaunchDaemons/limit.maxfiles.plist

/Library/LaunchDaemons/limit.maxproc.plist

After a reboot, a re ran the ulimit -a command and the changes were now in effect.  I monitored the system log and these errors are now gone.

Nov 11 11:27:34 hcstest smbd[416]: in openpam_read_chain(): /etc/pam.d/other: Too many open files
Nov 11 11:27:34 hcstest smbd[416]: in openpam_read_chain(): /etc/pam.conf: Too many open files




ulimit -a  

core file size          (blocks, -c) 0  
data seg size           (kbytes, -d) unlimited  
file size               (blocks, -f) unlimited  
max locked memory       (kbytes, -l) unlimited  
max memory size         (kbytes, -m) unlimited  
open files                      (-n) 524288  
pipe size            (512 bytes, -p) 1  
stack size              (kbytes, -s) 8192  
cpu time               (seconds, -t) unlimited  
max user processes              (-u) 2048  
virtual memory          (kbytes, -v) unlimited
Leave Comments