0

I know, when we run application in shell for a large website, we'd better set ulimit for our shell,

But most of the service is started by systemd/sysv.

Do I need set the ulimit in the service script (/etc/init.d) ?

2

You would normally set the ulimit on the user the service runs as in something like /etc/security/limits.conf.

For example, if the web service is running as www-data, you would add an entry for www-data to /etc/security/limits.conf setting the relevant limits.

If the process runs as root then it's more complicated given the limits in /etc/security/limits.conf would then apply to all root owned processes.

One issue with setting the limits in /etc/security/limits.conf is that it relies on processes going through the PAM stack.

In the case of services and daemons which don't do that, then yes, modifying the relevant service scripts is an acceptable approach. It's probably necessary to do this on a per process basis, and depending on your distribution, service start scripts are usually package managed meaning you'll get conflicts every time you upgrade.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.