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?
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!