proc's limit and ulimit -f don't match

Solution 1:

Ulimits are inherited from the parent process, if f.e. you login as root and su to the user. You WILL get different limits, than when logging directly onto the user.

The same issue is with start scripts if it's sysvinit. It's a bit different with systemd, but not by much.

PAM configuration decides in which cases are the limits loaded. You can check it in the man.

You should check if there are any files in /etc/security/limits.d/*.conf as they might override the defaults.

IIRC the defaults are set in limits.h, but I don't remember it's location on rhel5.

Solution 2:

In systems using systemctl to manage services like centos 7, there is a special place to set limits for systemctl services. You can put a config file in folder /etc/systemd/system/$service_name.service.d/ to overwrite the ulimit. You can put the configurations in service definition files too.

Example:

[Service]
LimitFSIZE=1024

The above configuration will overwrite the "file size limit" of the service.

see

Edit open file limit for SysV service in CentOS 7

https://fredrikaverpil.github.io/2016/04/27/systemd-and-resource-limits/

https://www.freedesktop.org/software/systemd/man/systemd.exec.html#Process%20Properties