ulimit命令

命令名称:

ulimit - 限制当前shell及其子进程的可用资源多少。

ulimit命令语法:

ulimit [OPTION]... number

number是数字,也可以是"unlimited“,代表”无穷大,不限制“。

ulimit命令讲解:

ulimit并不是针对用户做限制,而是针对当前shell。如果同一个用户同时登陆运行了两个shell,那么在其中一个shell中的ulimit限制不会影响另一个shell。如果想限制指定用户,请看这里:限制指定用户资源

我们可以通过将ulimit命令写在/etc/rc.local中,从而实现开机自动设置。另外,默认情况下,linux普通用户不能使用ulimit命令。

ulimit命令是bash的内置命令,man ulimit会直接跳转到man builtins的页面,可以翻页到比较后的位置查看ulimit项目,或者shell下直接help ulimit。

ulimit命令常用选项:

-H 使用硬资源控制
-S 使用软资源控制
-a 查看所有的当前限制
-n 能打开的最大文件描述符数
-t 限制最大的 CPU 占用时间(每秒)
-u 限制最大用户进程数
-v 限制虚拟内存大小(kB)

ulimit命令其他选项:

-c  the maximum size of core files created
-d  the maximum size of a process's data segment
-e  the maximum scheduling priority (`nice')
-f  the maximum size of files written by the shell and its children
-i  the maximum number of pending signals
-l  the maximum size a process may lock into memory
-m  the maximum resident set size (has no effect on Linux)
-n  the maximum number of open file descriptors
-p  the pipe buffer size
-q  the maximum number of bytes in POSIX message queues
-r  the maximum real-time scheduling priority
-s  the maximum stack size
-x  the maximum number of file locks

ulimit命令实例:

ulimit -HSn 65536  #硬资源和软资源同时限制为最大打开文件描述符数65546
ulimit -v ulimited  #将虚拟内存限制改为无限制
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值