View the number of handles occupied by system processes in CentOS

Source: Internet
Author: User
--- 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/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.