Error resolution due to excessive number of operating files in Linux systems

Source: Internet
Author: User
Tags file size posix

Linux Open File number too many open files solution

Too many open files is prompted because the number of file/socket connections that the program opens exceeds the system setting.

To view the maximum allowable number of open files per user

The code is as follows:

Ulimit-a

fdipzone@ubuntu:~$ ulimit-a

Core file size (blocks,-c) 0

Data seg Size (Kbytes,-D) Unlimited

Scheduling Priority (-e) 20

File size (blocks,-f) Unlimited

Pending Signals (I.) 16382

Max locked Memory (Kbytes, L) 64

Max memory Size (Kbytes, M) Unlimited

Open files (-N) 1024

Pipe Size (bytes, p) 8

POSIX message queues (bytes,-Q) 819200

Real-time priority (-R) 0

Stack size (Kbytes,-s) 8192

CPU time (seconds,-t) unlimited

MAX User Processes (-u) Unlimited

Virtual Memory (Kbytes,-V) Unlimited

File locks (-X) Unlimited

where open files (-N) 1024 indicates that the maximum number of files allowed for each user is 1024

View the number of files currently open on the system

The code is as follows:

lsof | Wc-l

Watch "Lsof | Wc-l "

View the number of open files for a process

The code is as follows:

Lsof-p PID | Wc-l

LSOF-P 1234 | Wc-l

Set the open files numeric method

The code is as follows:

Ulimit-n 2048

fdipzone@ubuntu:~$ Ulimit-n 2048

fdipzone@ubuntu:~$ ulimit-a

Core file size (blocks,-c) 0

Data seg Size (Kbytes,-D) Unlimited

Scheduling Priority (-e) 20

File size (blocks,-f) Unlimited

Pending Signals (I.) 16382

Max locked Memory (Kbytes, L) 64

Max memory Size (Kbytes, M) Unlimited

Open files (-N) 2048

Pipe Size (bytes, p) 8

POSIX message queues (bytes,-Q) 819200

Real-time priority (-R) 0

Stack size (Kbytes,-s) 8192

CPU time (seconds,-t) unlimited

MAX User Processes (-u) Unlimited

Virtual Memory (Kbytes,-V) Unlimited

File locks (-X) Unlimited

This sets the maximum allowable number of open files for the current user to 2048, but this setting is restored to the default value after the reboot.

Permanent Settings method

The code is as follows:

Vim/etc/security/limits.conf

In the final join

The code is as follows:

* Soft nofile 4096

* Hard Nofile 4096

The top * represents all users and can set a user as needed, such as

The code is as follows:

Fdipzone Soft Nofile 8192

Fdipzone Hard Nofile 8192

After the change, the cancellation will be effective.

Linux Argument list too long error resolution

The last time you need to delete all files in the/tmp directory, the number of files is larger.

The code is as follows:

ls-lt/tmp | Wc-l

385412

System prompts error Argument list too long after using RM *

The reason is that under Linux, attempts to pass too many parameters to a system command (LS *; CP *; RM *; cat *; etc) , a Argument list too long error appears.

The workaround is as follows:

Use Find-exec traversal, and then perform the deletion.

The code is as follows:

sudo find/tmp-type f-exec rm {};

Related Article

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.