Maximum number of open files for Linux

Source: Internet
Author: User
Tags cpu usage

There is a limit to the number of file handles that each user, user, and each process can open at the same time under Linux. Do not use the file handle to close.

First, view the maximum number of open files

1. Check the system and the maximum number of open files

Cat/proc/sys/fs/file-max//This file specifies the maximum number of file handles that can be allocated

    

2. View the maximum number of open files for the current user

      1. # Ulimit-hn//view hard limit
      2. # ULIMIT-SN//view soft limit

3. View the number of open files for all processes lsof |wc-l View the number of files opened by a process lsof-p PID |wc-l Two, set the maximum number of open files

1, the system and the settings

      1. # vi/etc/sysctl.conf
      2. Fs.file-max = 100000
      3. Immediate effect Sysctl-p

2. User-level settings

    1. Vi/etc/security/limits.conf
    2. The limits.conf format is as follows:

      <domain> <type> <item> <value>

      <domain>: You can specify a single user name, @ Group name, all users (*)

      Type: Soft (refers to the setting value of the current system), hard (indicates the maximum value that can be set in the system) and-(indicates that both soft and hard values are set)

For the limits.conf file configuration to take effect, you must make sure that the pam_limits.so file is added to the startup file.

Basic System Setup Command--ulimit

Syntax: ulimit [-ahs][-c <core file Cap >][-d < data section size >][-f < file size >][-m < Memory size >][-n < number of files >][-p < buffer size >][-s < stack size >][-t < CPU Time >][-u < program number >][-v < virtual memory size;]

Supplemental Note: Ulimit is the shell built-in Directive, Resources that can be used to control shell execution programs.

Parameters
-a displays the current resource limit settings.
-C <core File cap > set the maximum value of the core file, in chunks.
-D < data section size > Maximum value of the Program Data section, in kilobytes.
-F < file size > The largest file the shell can create, in chunks.
-H sets the hard limit for the resource, which is the limit set by the administrator.
-m < memory size > Specifies the maximum amount of memory that can be used, in kilobytes.
-N < number of files > specifies the maximum number of files that can be opened at the same time.
-p < buffer size > Specifies the size of the pipe buffer, in 512 bytes.
-s < stack size > specifies the upper limit of the stack in kilobytes.
-S sets the elastic limit for the resource.
-T <CPU time > Specifies the maximum CPU usage time in seconds.
-U < number of programs > number of programs the user can open.
-v < virtual memory size > Specifies the maximum amount of virtual memory that can be used, in kilobytes.

Maximum number of open files for Linux

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.