Check number of file descriptors opened by process
Fri, 03/25/2011 - 11:51 — sandipTo check on the file descriptors opened by process:
lsof -p {PID} | awk '$4 ~ /^[0-9]/ {print $4}' | wc -l
alternately:
ls -1 /proc/{PID}/fd | wc -l
To check all file descriptors opened by a user:
lsof -u {user} | awk '$4 ~ /^[0-9]/ {print $4}' | wc -l
By 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 -Sn
To increase edit the "/etc/security/limits.conf" file for corresponding user:
{user} soft nofile 4096
{user} hard nofile 4096
To check if the new limits has been applied type `ulimit -n` after you get a new shell.
Resolving df and du reporting different output
Thu, 01/14/2010 - 14:54 — sandipIf df and du give different output of disk usage. Then, most probably it is due to "open file descriptors".
Run `lsof +L1` to get a listing of open files that have been unlinked or removed. Note the file size and kill or restart the respective service.
Reference: walkernews.net
- sandip's blog
- Login or register to post comments
- Read more