ulimit is used to limit the resources that each user can use, such as CPU, memory, handles, etc. The following takes CentOS 6.5 as an example to summarize.
Command format:
<span class="hljs-built_in">ulimit</span> [-SHacdefilmnpqrstuvx]
Command format:
<span class="hljs-built_in">ulimit</span> [-SHcdefilmnpqrstuvx] [<span class="hljs-built_in">limit</span>]
Add the limit value after the command you are viewing to adjust a certain limit, but it is only effective for the current login shell.
Parameter S means setting a soft limit; parameter H means setting a hard limit; when neither is specified, it means setting both the soft limit and the hard limit to the specified values.
所谓永久,是指每次登陆shell时,都会按配置重新设定ulimit ,以达到永久生效的效果。
添加如下内容:
关于该文件的配置方式请参考后文
[root@CentOS646506 ~]# vim /etc/security/limits.conf <span class="hljs-bullet">* </span>hard nproc 64000 <span class="hljs-bullet">* </span>soft nproc 64000 <span class="hljs-bullet">* </span>hard nofile 64000 <span class="hljs-bullet">* </span>soft nofile 64000
以上内容表示,将-u 和-n 的软限制和硬限制同时修改为64000。
添加如下内容:
[root<span class="hljs-variable">@CentOS646506</span> ~]<span class="hljs-comment"># vim /etc/pam.d/login</span> session required pam_limits.so
以上内容表示,在登录时使用pam 管理limit 。
添加如下内容
[root@CentOS646506 ~]<span class="hljs-comment"># vim /etc/profile</span> <span class="hljs-built_in">ulimit</span> -u 64000 <span class="hljs-built_in">ulimit</span> -n 64000
每次登陆shell后,会初始执行这两条ulimit 命令,并使其生效。
重新登录或使用source /etc/profile 立即生效。
source使当前shell对指定文件内容生效。
格式:
<span class="hljs-tag"><<span class="hljs-name">domain</span>></span> <span class="hljs-tag"><<span class="hljs-name">type</span>></span> <span class="hljs-tag"><<span class="hljs-name">item</span>></span> <span class="hljs-tag"><<span class="hljs-name">value</span>></span>
The above is the detailed content of Detailed explanation of ulimit command using CentOS 6.5 as an example. For more information, please follow other related articles on the PHP Chinese website!