ulimit set one or two

Display system open process and file limit information
#ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 30494
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 65535
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, - q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 10240
cpu time (seconds, -t) unlimited
max user processes (-u) 30494
virtual memory (kbytes, -v) unlimited
file locks ( -x) unlimited
 
"open files (-n) 65535" is the Linux operating system's limit on the number of file handles opened by a process, including the number of open SOCKETs.
 
The ulimit command can modify its value, ulimit -SHn 65535, but it is only valid for the current usage environment of the currently logged-in user, and will be invalid after the system restarts or the user exits.
 
/proc/sys/fs/file-max configures the total system limit, /proc/sys/fs/file-nr, you can also see the number of file handles currently used by the entire system.
 
lsof can easily see which handles a process has opened to
view the number of open files of the current process: lsof -p PID | wc -l
to view the number of open files of the current port: lsof -i:PORT | wc -l
Before using lsof It should be noted that lsof is not suitable for viewing a process or port with a high number of connections or a dynamically changing number.
 
Limit the maximum number of processes per user
ulimit -u 65535
 
Limit the number of files each process can open
ulimit -n 65535
 
If you want to permanently change the configuration information, you still need to modify the configuration file /etc/securuty/limits.conf, and log in again to take effect

  • soft noproc 65535
  • hard noproc 65535
  • soft nofile 65535
  • Hard nofile 65535
    is to limit the maximum number of threads and files for any user.
    Set to 65535 as an asterisk to represent the whole world. You can also make different restrictions for different users.
    There are two restriction levels hard and soft. The corresponding parameter switches are - H and -S, the hard limit prevents non-root users from increasing (exceeds) the set value, and the soft limit allows non-root users to increase to the hard limit value. Usually, the hard value and the soft value are set to the same value.
     
    Reference:
    http://www.cnblogs.com/ibook360/archive/2012/05/11/2495405.html
    https://www.linuxidc.com/Linux/2017-06/145313.htm

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324809228&siteId=291194637