On Mon, Nov 14, 2022 at 06:50:53AM -0800, Thomas Nyberg wrote: > Thanks for the help! That worked well with bash (i.e. if I set both > /etc/security/limits.conf and /etc/sysctl.conf, then `ulimit -aH` returns > what you'd expect). > > However, I have a server process and when I check its limits by looking at > `/proc/$PID/limits`, the hard limit is not raised there. I have figured out > that I can raise it by executing e.g. `prlimit --pid=$PID > --nofile=1024:16777216`, but I haven't found a way for it to make it stick > across reboots. The process itself is running as root.
Resource limits are inherited from one's parent process. So, you need to figure out the full chain of processes leading up to your service. If it's run by systemd, then the chain should be relatively short -- systemd runs with the limits are placed by the kernel, followed by whatever adjustments systemd makes to itself internally. Then it reads a service unit file, and spawns your service according to the instructions therein. The unit file can include resource limit declarations. See systemd.exec(5) and search for PROCESS PROPERTIES. If it's *not* a systemd unit file, or if you're not using systemd at all, then the chain of processes can be longer. There could be a shell involved, for example. You'd need to check for resource limits being applied at each step. It should be noted that /etc/security/limits.conf will almost certainly do nothing for services. It's a configuration file for pam_limits, which is generally used for login type things. Not services.