Check the open FD limit for a given process in Linux

后端 未结 7 1792
粉色の甜心
粉色の甜心 2020-12-04 10:13

I recently had a Linux process which “leaked” file descriptors: It opened them and didn\'t properly close some of them.

If I had monitored this, I could tell – in adv

7条回答
  •  执笔经年
    2020-12-04 10:54

    to see the top 20 file handle using processes:

    for x in `ps -eF| awk '{ print $2 }'`;do echo `ls /proc/$x/fd 2> /dev/null | wc -l` $x `cat /proc/$x/cmdline 2> /dev/null`;done | sort -n -r | head -n 20
    

    the output is in the format file handle count, pid, cmndline for process

    example output

    701 1216 /sbin/rsyslogd-n-c5
    169 11835 postgres: spaceuser spaceschema [local] idle
    164 13621 postgres: spaceuser spaceschema [local] idle
    161 13622 postgres: spaceuser spaceschema [local] idle
    161 13618 postgres: spaceuser spaceschema [local] idle
    

提交回复
热议问题