本文共 2717 字,大约阅读时间需要 9 分钟。
轉載自
While administrating a box, you may wanted to find out what a processes is doing and find out how many file descriptors (fd) are being used. You will surprised to find out that process does open all sort of files:
=> Actual log file=> /dev files
=> UNIX Sockets
=> Network sockets
=> Library files /lib /lib64
=> Executables and other programs etc
In this quick post, I will explain how to to count how many file descriptors are currently in use on your Linux server system.
To find out PID for mysqld process, enter:
# ps aux | grep mysqld
OR# pidof mysqld
Use the lsof command or /proc/$PID/ file system to display open fds (file descriptors), run:
# lsof -p 28290 # lsof -a -p 28290
OR# cd /proc/28290/fd # ls -l | less
You can count open file, enter:# ls -l | wc -l
To count the number of open file handles of any sort, type the following command:
# lsof | wc -l
Sample outputs: 5436
Type the following command:
# sysctl fs.file-nr
Sample outputs: fs.file-nr = 1020 0 70000
Where,
You can use the following to find out or set the system-wide maximum number of file handles:
# sysctl fs.file-max
Sample outputs: fs.file-max = 70000
See how to set for more information.
/proc (or procfs) is a pseudo-file system that it is dynamically generated after each reboot. It is used to access kernel information. procfs is also used by Solaris, BSD, AIX and other UNIX like operating systems. Now, you know how many file descriptors are being used by a process. You will find more interesting stuff in /proc/$PID/file directory:
SEE ALSO: /PROC RELATED FAQ/TIPS
/proc is an essentials file system for sys-admin work. Just browser through our previous article to get more information about /proc file system:
转载地址:http://awpgi.baihongyu.com/