ulimit

-a:显示当前所有的资源限制

-c:core文件大小

-f:设置创建文件的最大值

-n:设置内核可以同时打开的文件描述符的最大值

-p:设置管道缓冲区的最大值

-s:设置堆栈的最大值

-u:用户最多可开启的程序数目

创建文件的最大值

# ulimit -f 10
# cat vim-6.4.tar.bz2 > test
File size limit exceeded (core dumped)
# ll test
-rwxrwxrwx 1 root root 10240 May 16 2017 test*
# ulimit -f unlimited //无限制

文件描述符的最大值(临时)

# ulimit -n //默认
1024
# ulimit -n 10240 //修改
# ulimit -n
10240
int i = 1;
while(i++)
{
int fd = open("./hello.tk", O_RDONLY);
if(fd < 0)
{
perror("open");
printf("i = %d\n", i);
return -1;
}
} # ./a.out
open: Too many open files
i = 10239

limits.conf

# vi /etc/security/limits.conf
<domain> <type> <item> <value> <domain> can be:
- a user name
- a group name, with @group syntax
- the wildcard *, for default entry
- the wildcard %, can be also used with %group syntax, for maxlogin limit
- NOTE: group and wildcard limits are not applied to root. To apply a limit to the root user, <domain> must be the literal username root. <type> can have the two values:
- "soft" for enforcing the soft limits
- "hard" for enforcing hard limits <item> can be one of the following:
- core - limits the core file size (KB)
- data - max data size (KB)
- fsize - maximum filesize (KB)
- memlock - max locked-in-memory address space (KB)
- nofile - max number of open files
- rss - max resident set size (KB)
- stack - max stack size (KB)
- cpu - max CPU time (MIN)
- nproc - max number of processes
- as - address space limit (KB)
- maxlogins - max number of logins for this user
- maxsyslogins - max number of logins on the system
- priority - the priority to run user process with
- locks - max number of file locks the user can hold
- sigpending - max number of pending signals
- msgqueue - max memory used by POSIX message queues (bytes)
- nice - max nice priority allowed to raise to values: [-20, 19]
- rtprio - max realtime priority
- chroot - change root to directory (Debian-specific)

文件描述符的最大值(永久)

*      soft    nofile     10240
* hard nofile 10240
# reboot
# ulimit -n
10240

系统文件描述符的最大值

# cat /proc/sys/fs/file-max
100367
# echo 100367 > /proc/sys/fs/file-max

ulimit用法的更多相关文章

  1. 通过ulimit改善linux系统性能(摘自IBM)

    本文介绍了 ulimit 内键指令的主要功能以及用于改善系统性能的 ulimit 用法.通过这篇文章,读者不仅能够了解 ulimit 所起的作用.而且能够学会怎样更好地通过 ulimit 限制资源的使 ...

  2. 理解Docker(1):Docker 安装和基础用法

    本系列文章将介绍Docker的有关知识: (1)Docker 安装及基本用法 (2)Docker 镜像 (3)Docker 容器的隔离性 - 使用 Linux namespace 隔离容器的运行环境 ...

  3. 常见linux命令释义(第七天)——ulimit 与变量内容的删除替代与替换。

    linux是一个多用户多任务的系统,不同于windows的单人多任务操作系统.再linux上,在同一个时间点上,可以有多个人同时执行多个任务. 那么假若有10个用户,同时打开了100个100M的文件. ...

  4. ulimit命令

    原文链接 linux下默认是不产生core文件的,要用ulimit -c unlimited放开 概述 系统性能一直是一个受关注的话题,如何通过最简单的设置来实现最有效的性能调优,如何在有限资源的条件 ...

  5. 优化系统资源ulimit《高性能Linux服务器构建实战:运维监控、性能调优与集群应用》

    优化系统资源ulimit<高性能Linux服务器构建实战:运维监控.性能调优与集群应用> 假设有这样一种情况,一台Linux 主机上同时登录了10个用户,在没有限制系统资源的情况下,这10 ...

  6. linux 通过 ulimit 改善系统性能

    https://www.ibm.com/developerworks/cn/linux/l-cn-ulimit/ 概述 系统性能一直是一个受关注的话题,如何通过最简单的设置来实现最有效的性能调优,如何 ...

  7. linux中ulimit作用

    一.作用 Linux对于每个用户,系统限制其最大进程数.为提高性能,可以根据设备资源情况,设置各linux 用户的最大进程数. ulimit主要是用来限制进程对资源的使用情况的,它支持各种类型的限制, ...

  8. LINUX ulimit命令

    概述 系统性能一直是一个受关注的话题,如何通过最简单的设置来实现最有效的性能调优,如何在有限资源的条件下保证程序的运作,ulimit 是我们在处理这些问题时,经常使用的一种简单手段.ulimit 是一 ...

  9. Linux ulimit 系统资源控制

    ulimit 的功能和用法 ulimit 功能简述 假设有这样一种情况,当一台 Linux 主机上同时登陆了 10 个人,在系统资源无限制的情况下,这 10 个用户同时打开了 500 个文档,而假设每 ...

随机推荐

  1. Carve Visual Studio2015编译

    下载Carve库  https://github.com/folded/carve 目录结构如下: 用Visual Studio2015打开,点击右键,生成即可 在bin目录下生成了   .lib文件 ...

  2. Spring事务的隔离级别和传播机制

    七个传播机制:(红色字体的代表如果不设置传播机制时候默认的)PROPAGATION_REQUIRED-支持当前事务;如果不存在,创建一个新的. PROPAGATION_SUPPORTS-支持当前事务; ...

  3. PAT 甲级 1053 Path of Equal Weight (30 分)(dfs,vector内元素排序,有一小坑点)

    1053 Path of Equal Weight (30 分)   Given a non-empty tree with root R, and with weight W​i​​ assigne ...

  4. oracle数据库死锁原因及分析

    定义: 当两个用户希望持有对方的资源时就会发生死锁. 即两个用户互相等待对方释放资源时,oracle认定为产生了死锁,在这种情况下,将以牺牲一个用户作为代价,另一个用户继续执行,牺牲的用户的事务将回滚 ...

  5. (四)java对象的结构和对象的访问定位

    在HotSpot虚拟机中,对象在内存中存储的布局可以分为3块区域:对象头(Header).实例数据(Instance Data)和对齐填充(Padding). 一. 对象头 HotSpot虚拟机的对象 ...

  6. ubuntu 18.04安装jdk8和eclipse

    JDK8的安装 1.安装ppa sudo add-apt-repository ppa:webupd8team/java sudo apt-get update 2.安装JDK sudo apt-ge ...

  7. python迭代器、生成器、装饰器之生成器

    python中只要函数内部包含有yield关键字,那么函数名()的到的结果就是生成器,并且不会执行函数内部代码,通过__next__()或者next()函数可以获取值,每调用一次,都会取出一个值,无值 ...

  8. OpenCV直方图(直方图、直方图均衡,直方图匹配,原理、实现)

    1 直方图 灰度级范围为 \([0,L-1]\) 的数字图像的直方图是离散函数 \(h(r_k) = n_k\) , 其中 \(r_k\) 是第\(k\)级灰度值,\(n_k\) 是图像中灰度为 \( ...

  9. 基于MSP430G2231实现的频率计

    基于MSP430G2231实现的频率计 声明:引用请注明出处http://blog.csdn.net/lg1259156776/ 系列博客说明:此系列博客属于作者在大三大四阶段所储备的关于电子电路设计 ...

  10. 2、2 唯一验证,这里我们强调后台的唯一验证&在保存之前进行验证

    后台 —————————————————————————————————————————————— @RequestMapping("/uniqueNameCheck") publ ...