2

I Have an Ubuntu 16.04 server.

When I run as root, ulimit -n I get 1024.

When I run it as my user I get 65535.

But I want to make sure that all users, including root has the open files limit set to 65535.

The problem is that I've done everything I know to change it and still, for root it shows 1024.

Here are the things I've done:

root@sensu:/etc/security/limits.d# cat 90-nofiles.conf
* soft     nproc          65535
* hard     nproc          65535
* soft     nofile         65535
* hard     nofile         65535

root@sensu:/etc/security# grep nofile limits.conf
#        - nofile - max number of open files
*   soft     nofile         65535
*   hard     nofile         65535

root@sensu:/etc/security# grep file-max  /etc/sysctl.conf
fs.file-max = 65536

Ofcourse I ran sysctl -p.

The problematic process is redis:

root@sensu:/proc# grep "open files" /proc/1487/limits
Max open files            4096                 4096                 files

Looking at the redis init file:

root@sensu:/proc# grep ulimit /etc/init.d/redis-server
    ulimit -n 100001

As you see in the examples, there's no reason for this limit to be 1024 and still... it is 1024.

What could be the reason? Where is that setting that I'm missing?

Itai Ganot
  • 10,424
  • 27
  • 88
  • 143
  • Might want to check root's startup files (.bash_profile, etc.) that apply to the interactive shell where you got 1024, to ensure that the limit is not requested in any of them. – MadHatter Feb 20 '17 at 13:18
  • I have, sorry for not mentioning it. – Itai Ganot Feb 20 '17 at 13:19

1 Answers1

3

I found the answer in this stackoverflow post.

It seems like adding:

* soft     nofile         65535
* hard     nofile         65535 

Is enough when editing the limit for non-root users.

But in order to change the limits for root user as well, it must be added explicitly:

root soft     nofile         65535
root hard     nofile         65535

Now it works as intended:

root@sensu:~# ulimit -n
65535
Itai Ganot
  • 10,424
  • 27
  • 88
  • 143