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 {};