To check on the file descriptors opened by process:
lsof -p {PID} | awk '$4 ~ /^[0-9]/ {print $4}' | wc -lalternately:
ls -1 /proc/{PID}/fd | wc -lTo check all file descriptors opened by a user:
lsof -u {user} | awk '$4 ~ /^[0-9]/ {print $4}' | wc -lBy default the hard and soft limits for a single process are set to 1024 on linux systems. To check on the limits:
ulimit -Hn
ulimit -SnTo increase edit the "/etc/security/limits.conf" file for corresponding user:
{user} soft nofile 4096
{user} hard nofile 4096To check if the new limits has been applied type `ulimit -n` after you get a new shell.
- sandip's blog
- Login or register to post comments
Comments
su - {USER} -c 'ulimit -Ha' -s /bin/bashListing of top 10 pids and processes showing current open and max open files limit:
# lsof -n 2>/dev/null | awk '$4 ~ /^[0-9]/ {print $1,$2}' | sort | uniq -c | sort -nr | head | while read nr name pid ; do printf "%10d / %-10d %-15s (PID %5s)\n" $nr $(awk '/open files/ {print $5}' /proc/$pid/limits) $name $pid; doneResource limits in linux can be set in various locations based on the type of requirement.
/etc/security/limits.conf is part of pam_limits and so the limits that are set in this file is read by pam_limits module during login sessions, so pam_limits will not affect the daemon processes.
/etc/sysctl.conf sets the maximum amount of resource that can be used by all users/processes put together via fs.file-max. fs.file-nr gives the current usage and max limit set.
Daemons are started as part of init so pam_limits don't help. ulimit command is used to set the limits of the shell, so is necessary to include ulimit within the initialization script itself like in apachectl startup script. Thus to increase the max open file descriptors from the default of 4096 to 10000, hardcode the below in the startup script itself.
ulimit -n 10000# cat /proc/{PID}/limits