--- View the system default maximum number of file handles, the system default is 1024 # ulimit-n1024 ---- view the number of handles opened by the current process # lsof-n | awk & #39; {print $2} & #39; | sort | uniq-c | sort-nr | more131242045724244
--- View the maximum number of file handles by default. the default value is 1024.
# Ulimit-n
1024
---- View the number of handles opened by the current process
# Lsof-n | awk '{print $2}' | sort | uniq-c | sort-nr | more
131 24204
57 24244
57 24231 ........
The first column is the number of opened handles, and the second column is the process ID.
You can view the process name based on the ID.
# Ps aef | grep 24204
Nginx 24204 24162 99? 00:24:25/usr/local/nginx/sbin/nginx-s
Linux has hard and soft limits. You can use ulimit to set these two parameters. Run the following command as the root user:
# Ulimit-HSn 4096
In the preceding command, H specifies the hard size, S specifies the soft size, and n indicates setting the maximum number of opened file handles for a single process. I personally think it is best not to exceed 4096. after all, the more open file handles, the slower the response time. After the number of handles is set, the default value is restored after the system restarts. If you want to save it permanently, you can modify the. bash_profile file, and modify/etc/profile to add the above command to the end.
Original article: http://leequery.blog.163.com/blog/static/1684220962010101023743567/