Counting open files per process

Posted in :

原來,在Linux 裡同一個process 不能開太多檔案,會掛掉。要知道process 開了多少檔案的指令:

ls /proc/$pid/fd/ | wc -l

 


Have a look at the /proc/ file system:

ls /proc/$pid/fd/ | wc -l

To do this for all processes, use this:

cd /proc
for pid in [0-9]*
do
    echo "PID = $pid with $(ls /proc/$pid/fd/ | wc -l) file descriptors"
done

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *