lsof -u apache | wc -l で出てくるのはちょっと違う。


ls -l `ps auxwww|grep httpd|awk '{print $2}'|sort -u|sed "s/$/\/fd/"`|grep '\->'|wc -l




GNU/Linux - How Many Open Files?
What is an open file?

Is an open file a file that is being used, or is it an open file descriptor? A file descriptor is a data structure used by a program to get a handle on a file, the most well know being 0,1,2 for standard in, standard out, and standard error. The file-max kernel parameter refers to open file descriptors, and file-nr gives us the current number of open file descriptors. But lsof lists all open files, including files which are not using file descriptors - such as current working directories, memory mapped library files, and executable text files. To illustrate, let's examine the difference between the output of lsof for a given pid and the file descriptors listed for that pid in /proc.