Linux – Centos Monit ulimit not working

centoslinuxmonitulimit

Centos 5.9 I have set the below in /etc/security/limits.conf but when mMonit starts my processes the ulimit is still 1024. If I do ulimit -a it correctly shows 500000 as max open files. In /etc/sysctl.conf I have fs.file-max = 512000. Also root is the use that Monit is using to start the processes. I have rebooted and have the same issue.

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

* - nofile 655350

If I look at the process that Monit is managing I get:

[root@server1 ~]# cat /proc/8940/limits
Limit                     Soft Limit           Hard Limit           Units
Max cpu time              unlimited            unlimited            seconds
Max file size             unlimited            unlimited            bytes
Max data size             unlimited            unlimited            bytes
Max stack size            10485760             unlimited            bytes
Max core file size        0                    unlimited            bytes
Max resident set          unlimited            unlimited            bytes
Max processes             257124               257124               processes
Max open files            1024                 1024                 files
Max locked memory         32768                32768                bytes
Max address space         unlimited            unlimited            bytes
Max file locks            unlimited            unlimited            locks
Max pending signals       257124               257124               signals
Max msgqueue size         819200               819200               bytes
Max nice priority         0                    0
Max realtime priority     0                    0

Best Answer

I needed to set ulimit -n 500000 in the init file.