Linux中ulimit参数的永久生效。-u -s -c

本文介绍了如何在Linux系统中让ulimit参数永久生效的两种方法:一是通过编辑/etc/profile或~/.bash_profile文件,二是修改/etc/security/limits.conf文件,并在必要时调整/etc/security/limits.d/下的相关文件。详细步骤包括增加配置项、注释原有内容以及检查设置是否生效。

第一种,配置文件修改。

修改所有 linux 用户的环境变量文件:
    vi /etc/profile
    ulimit -u 10000
    ulimit -n 4096

或进入对应用户的配置文件:

vi ~/.bash_profile

添加同上

第二种,ulimits.conf配置文件修改。

vi /etc/security/limits.conf

进入后上面有详细的英文注解。


1、 /etc/security/limits.conf  中增加这些 


e3base  soft    core    65536 

e3base  hard    core    65536 

e3base  soft    nofile  1048576 

e3base  hard    nofile  1048576 

e3base  soft    stack   262144 

e3base  hard    stack   262144 

e3base  soft    nproc   65536 

e3base  hard    nproc   65536 

root    soft    core    65536 

root    hard    core    65536 

root    soft    nofile  1048576 

root    hard    nofile  1048576 

root    soft    stack   262144 

root    hard    stack   262144 

root    soft    nproc   65536


 2、如果limit.conf里面已经存在如下字样* ,并且1步骤更改不生效,将*字样注释掉

*  hard    stack   262144 

* soft    nproc   65536

 3、如果执行1、2步骤还没有生效那么进入 /etc/security/limits.d/对应的文件
        cb项目:/etc/security/limits.d/20-nproc.conf


添加文件内容:

e3base  soft    core    65536 

e3base  hard    core    65536 

e3base  soft    nofile  1048576 

e3base  hard    nofile  1048576 

e3base  soft    stack   262144 

e3base  hard    stack   262144 

e3base  soft    nproc   65536 

e3base  hard    nproc   65536 

root    soft    core    65536 

root    hard    core    65536 

root    soft    nofile  1048576 

root    hard    nofile  1048576 

root    soft    stack   262144 

root    hard    stack   262144 

root    soft    nproc   65536

 4、更新后执行 ulimit -a查看是否生效


 以上更改需要重新登录后生效
 

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值