Linux ulimit Command Usage resolution

Source: Internet
Author: User
Tags file size resource

Learn the use of ULIMIT commands.

Function Description: Controls the resources of the shell program.

Syntax: Ulimit [-ahs][-c

Supplemental Note: Ulimit is a shell-built directive that can be used to control the resources of shell execution programs.

Parameters

The code is as follows:

-a displays the current resource constraint settings.

-C

-D < data section size > The maximum value of the data section of the program, in kilobytes.

-F < file size > The largest file the shell can establish, in blocks.

-H set the hard limit of 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 > Specify the maximum number of files that can be opened at the same time.

-p < buffer size > Specifies the size of the pipe buffer, in units of 512 bytes.

-s < stacking size > Specifies the upper bound of the stack in kilobytes.

-S sets the flexibility limit for resources.

-T

-U < number of programs > The maximum number of programs that users can open.

-v < virtual memory size > Specify the maximum amount of virtual memory that can be used, in kilobytes.

Ulimit-a is used to display current user process restrictions.

Linux for each user, the system limits its maximum number of processes. To improve performance, you can set the maximum number of processes for each Linux user, depending on the device resource situation.

For example, set the maximum number of processes for a Linux user to 10,000:

Ulimit-u 10000

For Java applications that need to do many socket connections and keep them open,

It is best to modify the number of files that each process can open by using Ulimit-n XX, which defaults to 1024.

Ulimit-n 4096 increases the number of files that can be opened per process to 4096, and defaults to 1024

Some important settings for other suggestions that are set to unrestricted (unlimited) are:

Copy Code

The code is as follows:

Length of data segment: Ulimit-d Unlimited

Maximum memory size: Ulimit-m Unlimited

Stack size: Ulimit-s Unlimited

CPU Time: Ulimit-t Unlimited

Virtual Memory: Ulimit-v Unlimited

Sometimes the server needs to adjust the stack size parameter of Ulimit to unlimited infinite, the use of Ulimit-s unlimited can only be effective at the time of the shell, re-opened a shell is invalid.

Workaround:

Add Ulimit-s Unlimited on the last side of the/etc/profile.

And then:

# Source/etc/profile

Make the changes take effect immediately.

Possible problems:

If you encounter a similar error message

Ulimit:max User Processes:cannot Modify limit: Operation not allowed

Ulimit:open Files:cannot Modify limit: Operations not allowed

The above actions on root users will not prompt such restrictions, only for ordinary users have an impact, why?

We can go to study the document:/etc/security/limits.conf.

Description

Linux has a default ulimit limit for users, and this file can configure the user's hard configuration and soft configuration, and hard configuration is the upper limit.

A modification exceeding the upper limit would be an error such as "Disallowed operation".

You can add the relevant content at the end of the limits.conf file, as shown below:

That is, limit the maximum number of threads and files for any user to 10240.

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.