1

I have open files limit configured in /etc/security/limits.conf

*         hard    nofile      500000
*         soft    nofile      500000
root      hard    nofile      500000
root      soft    nofile      500000

When I start a process from shell, it works fine.

But there is one process that starts when the server boots.

# update-rc.d myprocess defaults 99

# cat /proc/1435/limits 
Limit                     Soft Limit           Hard Limit           Units     
....
Max open files            4096                 4096                 files     
....

Why this is happening?

Daniel Cukier
  • 823
  • 1
  • 10
  • 18
  • What process specifically? Have you looked at the startup script to see if there is anything within the script that is adjusting the limits? – Zoredache Sep 25 '14 at 22:45
  • Nothing setting limits. The precess is simle daemon process: daemon --chdir=/home/ubuntu/myprocess --command=/home/ubuntu/myprocess/start.sh --respawn --name=myprocess – Daniel Cukier Sep 26 '14 at 02:30

1 Answers1

1

answer: try "man limits.conf" It's part of PAM: pluggable authentication modules

These limits are only applicable when using a program that was built to use PAM, usually doing an authentication (eg: login, su, sudo, ssh, ...) . When you login as root (via login, su, sudo, ... ) , you're authenticating, so your system is using the various PAM settings, including limits.conf.

When the system boots, there is no authentication, so no PAM configuration is ever read. Your daemon will use default settings. If later you (re)start it from root (for example using sudo su - on Ubuntu), then your current shell gets the limits.conf settings and whatever is run by it will also inherit them.

possible solutions: Since root can override the limits anyway, you should instead change the settings in the startup script of your daemon(s). For example with ulimit (search inside "man bash" )

You might also try using a construct like: su - -c 'daemon ... =myprocess' in your startup script. Maybe this additional su will use PAM and change the limits. I don't know. Tell us!

A.B
  • 11,090
  • 2
  • 24
  • 45