2

Here are the conf files and details, no matter what I did, soft openfiles wont go over 1024.

CENTOS 6.7 x86_64

cat /etc/security/limits.conf
* soft nproc 65535
* hard nproc 65535
* soft nofile 65535
* hard nofile 65535

cat /etc/security/limits.d/90-nproc.conf
* soft nproc 65535
* hard nproc 65535
* soft nofile 65535
* hard nofile 65535

root@server [~]# ulimit -n
65535

cat /etc/sysctl.conf
fs.file-max = 65535

cat /proc/1/limits
Max open files 1024 4096

it shows the correct limit when you run ulimit -n but when you check cat /proc/1/limits it shows 1024, all programs on the server stucked with 1024 openfiles limit, they are all running under the root user.

1
  • Can you explain what your outer problem is rather than telling us how you've attempted to solve it? Is there some specific process that needs a higher limit? If so, which process and how is that process being started? Feb 6, 2016 at 1:01

2 Answers 2

2

The limits you are changing affect only logged in users as they're implemented by PAM as part of the logging in process. They have no effect on processes started other ways, such as by systemd or init directly.

If you want to change the limit of processes that are started by something other than a user logging in, you need to do it in that process itself. Processes that have root permissions can change their limits however they want.

# cat /proc/self/limits  | grep -i open
Max open files            1024                 1024                 files     

# ulimit -Hn 8192
# ulimit -n 8192
# cat /proc/self/limits  | grep -i open
Max open files            8192                 8192                 files     

# ulimit -Hn 65536
# ulimit -n 65536
# cat /proc/self/limits  | grep -i open
Max open files            65536                65536                files
6
  • Thank you, I see now. However, is it possible to force all scripts to use system based max open files or do i have to edit scripts and specify limits ?
    – Matt
    Feb 6, 2016 at 1:10
  • There is no "system based max open files", as far as I know. Again, it depends what it is you're trying to do, which you still haven't told us. Whatever launches these scripts either understands limits or doesn't. If it does, tell it to set the limits how you want. If it doesn't, then set the limits before launching the thing that launches these scripts. For example, systemd supports LimitNOFILE. Feb 6, 2016 at 1:13
  • It is the cPanel server system running on the server with the proc id 2001 root 2001 cpsrvd (SSL) - waiting for connections cat /proc/2001/limits | grep -i open Max open files 1024 4096 files ---- I guess i need to contact them, I was developing a script under their control panel.
    – Matt
    Feb 6, 2016 at 1:18
  • How is the control panel launched? By systemd? Feb 6, 2016 at 1:20
  • The interesting thing is, the same control panel with the same version under the CentOS 7 reads the limit from this file /etc/systemd/system.conf and shows what limit sets in the system.conf file. But in centos 6 i couldnt find where it gets the limit. From centos7 i see yes it is lunched by systemd
    – Matt
    Feb 6, 2016 at 1:26
2

Limits.conf and Root

Using * in limits.conf only applies to all users except root.

If you want to set limits on root, you have to specify root instead of (or in addition to) *.

Example:

root soft nproc 65535
root hard nproc 65535
root soft nofile 65535
root hard nofile 65535

Or you can change the limit in your script manually as mentioned in another answer.

Note

This assumes your application utilizes pam. If not, you have to set the limit in the script.

6
  • He's already got that part covered. Notice the output of ulimit -n in his question? His issue seems to be with processes that weren't created by a user logging in. Feb 6, 2016 at 1:04
  • Yup, I have run into this one before. You have to specify root by name. This also assumes the application actually utilizes pam.
    – Aaron
    Feb 6, 2016 at 1:06
  • Thank you my friend. I did change it to the root and as David said the scripts itself needs to be set with the limit. But thank you for the information.
    – Matt
    Feb 6, 2016 at 1:11
  • Np. If you have to set it in the script, then the app is not calling pam.
    – Aaron
    Feb 6, 2016 at 1:12
  • and if it isn't calling pam, then any changes you would have made in limits.conf would never have been applied. sigh
    – Aaron
    Feb 6, 2016 at 1:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .