If you are getting error “Too many open files (24)” then your application/command/script is hitting max open file limit allowed by linux. You need to increase open file limit as below:
Open file /etc/security/limits.conf
Paste following towards end:
* hard nofile 500000 * soft nofile 500000 root hard nofile 500000 root soft nofile 500000
NOTE: 500000 is fair number.
This is needed to change limits for daemon processes.
Open /etc/pam.d/common-session.
Add following line:
session required pam_limits.so
Set this higher than user-limit set above.
Open /etc/sysctl.conf, and add the following:
fs.file-max = 2097152
Run:
sysctl -p
NOTE: This will increase the total number of files that can remain open system-wide.
Use following command to see max limit of file descriptors:
cat /proc/sys/fs/file-max
returns:
9223372036854775807
ulimit -Hn
returns:
1048576
ulimit -Sn
returns:
1024
su - www-data -c 'ulimit -aHS' -s '/bin/bash'
NOTE: Just replace www-data by the linux username to check limits for that user.
ps aux | grep process-name
cat /proc/XXX/limits
NOTE: Suppose, XXX is the PID found earlier.