ulimit命令参数及用法
ulimit命令参数及用法
功能说明:控制shell程序的资源。
补充说明:ulimit为shell内建指令,可用来控制shell执行程序的资源。
参 数:
-a 显示目前资源限制的设定。
-c 设定core文件的最大值,单位为区块。
-d <数据节区大小> 程序数据节区的最大值,单位为KB。
-f <文件大小> shell所能建立的最大文件,单位为区块。
-H 设定资源的硬性限制,也就是管理员所设下的限制。
-m <内存大小> 指定可使用内存的上限,单位为KB。
-n <文件数目> 指定同一时间最多可开启的文件数。
-p <缓冲区大小> 指定管道缓冲区的大小,单位512字节。
-s <堆叠大小> 指定堆叠的上限,单位为KB。
-S 设定资源的弹性限制。
-t 指定CPU使用时间的上限,单位为秒。
-u <程序数目> 用户最多可开启的程序数目。
-v <虚拟内存大小> 指定可使用的虚拟内存上限,单位为KB。
www.2cto.com
ulimit -a来查看所有限制值
01
core file size (blocks, -c) 0
02
data seg size (kbytes, -d) unlimited
03
scheduling priority (-e) 0
04
file size (blocks, -f) unlimited
05
pending signals (-i) 256590
06
max locked memory (kbytes, -l) 64
07
max memory size (kbytes, -m) unlimited
08
open files (-n) 1024
09
pipe size (512 bytes, -p) 8
10
POSIX message queues (bytes, -q) 819200
11
real-time priority (-r) 0
12
stack size (kbytes, -s) 10240
13
cpu time (seconds, -t) unlimited
14
max user processes (-u) 80920
15
virtual memory (kbytes, -v) unlimited
16
file locks (-x) unlimited
使用命令ulimit -HSn 65536可以立即生效.
ulimit -u 80920 在centos 6.2不能立即生效,还需要修改
vim /etc/security/limits.d/90-nproc.conf 原因应该是新特性
www.2cto.com
1
# Default limit for number of user's processes to prevent
2
# accidental fork bombs.
3
# See rhbz #432903 for reasoning.
4
5
* soft nproc 80920
注:/etc/security/limits.conf
www.2cto.com
limits.conf的工作原理:
limits.conf的后端是这样工作的:limits.conf是pam_limits.so的配置文件,然后/etc/pam.d/下的应用程序调用pam_***.so模块。譬如说,当用户访问服务器,服务程序将请求发送到PAM模块,PAM模块根据服务名称在/etc/pam.d目录下选择一个对应的服务文件,然后根据服务文件的内容选择具体的PAM模块进行处理。
limits.conf的格式
01
#<domain> can be:
02
# - an user name
03
# - a group name, with @group syntax
04
# - the wildcard *, for default entry
05
# - the wildcard %, can be also used with %group syntax,
06
# for maxlogin limit
07
设置需要被限制的用户名,组名前面加@和用户名区别。也可以用通配符*来做所有用户的限制。
08
#<type> can have the two values:
09
# - "soft" for enforcing the soft limits
10
# - "hard" for enforcing hard limits
11
hard 表明系统中所能设定的最大值。soft 的限制不能比hard 限制高。 www.2cto.com
12
#<item> can be one of the following:
13
# - core - limits the core file size (KB)
14
core - 限制内核文件的大小
15
# - data - max data size (KB)
16
date - 最大数据大小
17
# - fsize - maximum filesize (KB)
18
fsize - 最大文件大小
19
# - memlock - max locked-in-memory address space (KB)
20
memlock - 最大锁定内存地址空间
21
# - nofile - max number of open files
22
nofile - 打开文件的最大数目
23
# - rss - max resident set size (KB)
24
rss - 最大持久设置大小
25
# - stack - max stack size (KB)
26
stack - 最大栈大小
27
# - cpu - max CPU time (MIN)
28
cpu - 以分钟为单位的最多 CPU 时间
29
# - nproc - max number of processes
30
noproc - 进程的最大数目
31
# - as - address space limit (KB)
32
as - 地址空间限制
33
# - maxlogins - max number of logins for this user
34
maxlogins - 此用户允许登录的最大数目
35
# - maxsyslogins - max number of logins on the system
36
# - priority - the priority to run user process with
37
# - locks - max number of file locks the user can hold
38
# - sigpending - max number of pending signals
39
# - msgqueue - max memory used by POSIX message queues (bytes)
40
# - nice - max nice priority allowed to raise to values: [-20, 19]
41
# - rtprio - max realtime priority
42
#
43
#<domain> <type> <item> <value>
44
#
45
46
#* soft core 0
47
#* hard rss 10000
48
#@student hard nproc 20
49
#@faculty soft nproc 20
50
#@faculty hard nproc 50
51
#ftp hard nproc 0
52
#@student - maxlogins 4
53
54
# End of file
55
mysql soft core 2048000
56
mysql hard core 2048000
57
mysql soft nofile 819200
58
mysql hard nofile 819200
如果遇到“段错误”(segmentation fault)这样的问题,这主要就是由于Linux系统初始的堆栈大小(stack size)太小,可以使用ulimit -s
www.2cto.com
core - 限制内核文件的大小
何谓core文件,当一个程序崩溃时,在进程当前工作目录的core文件中复制了该进程的存储图像。core文件仅仅是一个内存映象(同时加上调试信息),主要是用来调试的。 core文件是个二进制文件,需要用相应的工具来分析程序崩溃时的内存映像。
nofile -打开文件的最大数目
对于需要做许多套接字连接并使它们处于打开状态的应用程序而言,最好通过使用 ulimit –n,或者通过设置nofile 参数,为用户把文件描述符的数量设置得比默认值高一些
转载于:https://blog.51cto.com/jingfeng/1905928
ulimit命令参数及用法相关推荐
- linux mount命令参数及用法详解
linux mount命令参数及用法详解 非原创,主要来自 http://www.360doc.com/content/13/0608/14/12600778_291501907.shtml. htt ...
- linux useradd(adduser)命令参数及用法详解(linux创建新用户命令)
linux useradd(adduser)命令参数及用法详解(linux创建新用户命令) useradd可用来建立用户帐号.帐号建好之后,再用passwd设定帐号的密码.而可用userdel删除帐号 ...
- linux中group命令详解,linux groupmod命令参数及用法详解
需要更改群组的识别码或名称时,可用groupmod指令来完成这项工作.接下来是小编为大家收集的linux groupmod命令参数及用法详解,希望能帮到大家. linux groupmod命令参数及用 ...
- linux的usermod命令参数,linux usermod命令参数及用法详解
linuxusermod命令参数及用法详解,linux修改用户账号信息命令,usermod可用来修改用户帐号的各项设定.接下来是小编为大家收集的linux usermod命令参数及用法详解,欢迎大家阅 ...
- linux中id命令的功能,Linux id命令参数及用法详解
Linux id命令参数及用法详解--Linux查看当前登陆用户uid,gid. 命 令:id 功能说明:查看显示目前登陆账户的uid和gid及所属分组及用户名 语 法:id [-g ...
- linux 内存 参数,linux free命令参数及用法详解(linux查看内存命令)
linux free命令参数及用法详解(linux查看内存命令) 2019年05月31日 | 萬仟网科技 | 我要评论 free指令会显示内存的使用情况,包括实体内存,虚拟的交换文件内存,共享内存区段 ...
- linux系统中mywho命令,linux查看在线用户 who命令参数及用法
linux who 命令 详解 Linux最常用命令之一 功能说明:显示目前登入系统的用户信息. 语 法:who [-Himqsw][--help][--version][am i][记录文件] 补充 ...
- linux nc参数,linux nc命令参数及用法详解之毕业纪
linux nc命令参数及用法详解 一.功能说明:强大的网络工具netcat 二.语 法:nc [options] [options] -d 后台模式 -e prog 程序 ...
- linux中的su-命令的功能,linux su命令参数及用法详解(linux切换用户命令)
linux su命令参数及用法详解(linux切换用户命令) 发布时间:2012-07-21 12:12:39 作者:佚名 我要评论 su的作用是变更为其它使用者的身份,超级用户除外,需要键入 ...
最新文章
- golang的临时对象池sync.Pool
- iOS多线程编程之多线程简单介绍(转载)
- javascript基础 (2)
- python列表的实现原理_python列表推导式原理和使用方法
- 机器学习模型中step与epoch,batch_size之间的关系
- Vision Transformer 论文解读
- HTML/CSS入门及基础
- 协议protocol
- 基于Linux解决登录ssh客户端失败问题—sshd error: could not load host key
- [求助]谁能给我讲解一下,iOS编程要如何实时显示采集到的图像???
- cant find python executable_gyp ERR! stack Error: Can't find Python executable 'python'
- ps怎么给人物抠图教程详细图解
- linux编译 __stdcall,Linux中是否有STDCALL?
- 由南非世界杯想到IDC
- 应届毕业生年薪50W,你敢相信吗?
- ubuntu 安装java运行环境,Ubuntu 安装java环境搭建
- CAD学习笔记中级课【CAD快捷键】
- 什么是Principle?能做什么?
- “马”道微信:全面拆解微信营销模式
- 万国数据登陆纳斯达克 宣布首次公开发行股票定价
热门文章
- 排兵布阵问题java语言_hdu 4539 郑厂长系列故事——排兵布阵
- 第075封“情书”:百撕不得其解Tearing Cloth<Entagma>Houdini 2018
- 固态硬盘系统迁移踩过的坑
- UI设计行业领域知识体系
- hive中的distribute by、sort by、cluster by
- 最常见的管理误区,你中招了吗?
- xml和html的区别和联系
- loadlibrary failed with error 126:找不到指定模块 解决方法
- Backstepping反步法控制四旋翼无人机(一)
- 优思学院|六西格玛管理的经典六步法