Check File Descriptor limits for a process



Published: 2020-08-29 10:20:09 +0000
Categories: BASH,

Language

BASH

Description

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

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    

Keywords

file descriptors, fds, file handles,

Latest Posts


Copyright © 2022 Ben Tasker | Sitemap | Privacy Policy
Available at snippets.bentasker.co.uk, http://phecoopwm6x7azx26ctuqcp6673bbqkrqfeoiz2wwk36sady5tqbdpqd.onion and http://snippets.bentasker.i2p
hit counter