ulimit 详解

ulimit [-SHacdflmnpstuv [limit]]
Provides control over the resources available to the shell and to processes started by it, on systems that
allow such control. The -H and -S options specify that the hard or soft limit is set for the given
resource. A hard limit cannot be increased once it is set; a soft limit may be increased up to the value of
the hard limit. If neither -H nor -S is specified, both the soft and hard limits are set. The value of
limit can be a number in the unit specified for the resource or one of the special values hard, soft, or
unlimited, which stand for the current hard limit, the current soft limit, and no limit, respectively. If
limit is omitted, the current value of the soft limit of the resource is printed, unless the -H option is
given. When more than one resource is specified, the limit name and unit are printed before the value.
Other options are interpreted as follows:
-a All current limits are reported
-c The maximum size of core files created
-d The maximum size of a process’s data segment
-f The maximum size of files created by the shell
-l The maximum size that may be locked into memory
-m The maximum resident set size
-n The maximum number of open file descriptors (most systems do not allow this value to be set)
-p The pipe size in 512-byte blocks (this may not be set)
-s The maximum stack size
-t The maximum amount of cpu time in seconds
-u The maximum number of processes available to a single user
-v The maximum amount of virtual memory available to the shell

If limit is given, it is the new value of the specified resource (the -a option is display only). If no
option is given, then -f is assumed. Values are in 1024-byte increments, except for -t, which is in sec-
onds, -p, which is in units of 512-byte blocks, and -n and -u, which are unscaled values. The return status
is 0 unless an invalid option or argument is supplied, or an error occurs while setting a new limit.

 

中文解释:

-H 设置硬限制.
-S 设置软限制.
-a 显示当前所有的资源限制.
-c size:设置core文件的最大值.单位:blocks
-d size:设置数据段的最大值.单位:kbytes
-f size:设置创建文件的最大值.单位:blocks
-l size:设置在内存中锁定进程的最大值.单位:kbytes
-m size:设置可以使用的常驻内存的最大值.单位:kbytes
-n size:设置内核可以同时打开的文件描述符的最大值.单位:n
-p size:设置管道缓冲区的最大值.单位:kbytes
-s size:设置堆栈的最大值.单位:kbytes
-t size:设置CPU使用时间的最大上限.单位:seconds
-v size:设置虚拟内存的最大值.单位:kbytes

 

配置文件: /etc/security/limits.conf 可以针对用户或组进行永久性 配置,使用命令的配置是临时的,针对当前用户的,不写文件的,退出当前shell就没有了的,写在配置文件中可以永久生效

留下评论

邮箱地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据