linux – “打开文件”ulimit:通过limits.conf控制

我正在敲打这个,我无法理解为什么它不起作用.我希望有人能够阐明这一点,或者没有这样做,给我一些调查途径的建议.

我有一个Red Hat 7.3系统(不要问)哪里需要增加wls81用户的打开文件限制.我以为我只是无法控制它,但它越来越看起来好像我只是遇到了我需要改变的用户的问题.我在/etc/security/limits.conf中添加了以下行:

wls81       soft    nofile      10100
wls81       hard    nofile      10240
madhatta    soft    nofile      10100
madhatta    hard    nofile      10240

正如我所知,正在调用pam_limits.so

[madhatta@server madhatta]$sudo grep limits /etc/pam.d/*
/etc/pam.d/login:session    required     /lib/security/pam_limits.so
/etc/pam.d/sshd:session    required     /lib/security/pam_limits.so
/etc/pam.d/su:session    required     /lib/security/pam_limits.so
/etc/pam.d/system-auth:session     required      /lib/security/pam_limits.so

当我像我一样ssh,我得到新的软限制,并可以增加到硬限制:

desktop> ssh server
Last login: Thu May 10 13:20:13 2012 from a.b.c.d
[madhatta@server madhatta]$ulimit -n 
10100
[madhatta@server madhatta]$ulimit -n 10200
[madhatta@server madhatta]$ulimit -n 
10200
[madhatta@server madhatta]$ulimit -n 10300
bash: ulimit: cannot modify open files limit: Operation not permitted

但是当我作为wls81用户使用时,我不能:

desktop> ssh wls81@server
Last login: Wed May  9 22:29:33 2012 from a.b.c.d
[wls81@server wls81]$ulimit -n
1024
[wls81@server wls81]$ulimit -n 10000
bash: ulimit: cannot modify open files limit: Operation not permitted

当我su – 每个用户时也会发生同样的事情.老实说,我不明白为什么这个用户无法重置其ulimits.有人有主意吗?

解决方法

嗯,这个谜就解决了.我发现当我做su – wls81时我得到了1024的限制,但是当我刚刚做了wls81时,我得到了新的,更高的限制.事实证明,wls81的.bash_profile调用了另一个脚本,该脚本又从系统上完全不同的用户调用一个环境设置脚本,该脚本执行了ulimit -n 1024.

当我删除该行时,wls81现在获得新的限制.

相关文章

在Linux上编写运行C语言程序,经常会遇到程序崩溃、卡死等异...
git使用小结很多人可能和我一样,起初对git是一无所知的。我...
1. 操作系统环境、安装包准备 宿主机:Max OSX 10.10.5 虚拟...
因为业务系统需求,需要对web服务作nginx代理,在不断的尝试...
Linux模块机制浅析 Linux允许用户通过插入模块,实现干预内核...
一、Hadoop HA的Web页面访问 Hadoop开启HA后,会同时存在两个...