Check File Descriptor limits for a process (BASH)
We've all seen too many open files
when we hit FD limits from time to time, but how do you check what the limits for a given process actually are?
The information is exposed within the /proc
filesystem
Details
- Language: BASH
Snippet
# Get the PID(s)
pidof $process_name
# take the pid from above, and check the limits
cat /proc/$pid/limits
# Get the PID(s)
pidof $process_name
# take the pid from above, and check the limits
grep "Max open files" /proc/$pid/limits
# Or, view all limits
cat /proc/$pid/limits
Usage Example
# pidof httpd
14247 14246 8667 1944
# cat /proc/14247/limits
Limit Soft Limit Hard Limit Units
Max cpu time unlimited unlimited seconds
Max file size unlimited unlimited bytes
Max data size unlimited unlimited bytes
Max stack size 10485760 unlimited bytes
Max core file size 0 unlimited bytes
Max resident set unlimited unlimited bytes
Max processes 14865 14865 processes
Max open files 1024 4096 files
Max locked memory 65536 65536 bytes
Max address space unlimited unlimited bytes
Max file locks unlimited unlimited locks
Max pending signals 14865 14865 signals
Max msgqueue size 819200 819200 bytes
Max nice priority 0 0
Max realtime priority 0 0
Max realtime timeout unlimited unlimited us
# grep "Max open files" /proc/14247/limits
Max open files 1024 4096 files