Is it possible to change the: soft limit and hard limit of a specific process? In my case, the process is mongod and a lot of web resources tell me to simply write ulimit -n in my terminal.

But how will the terminal know that I want to modify only the limits for the mongod process? Do I need to write the command somewhere in particular?

Also, once the above question is solved, is it possible to increase the hard limit since I am assuming that the above command works for the soft limit only.


What they try to tell is that you should first execute ulimit and then run mongod on the same shell session. This way Mongo DB process will have it's limits changed.

As you probably want to start Mongo DB using the startup script, the simplest solution would be modify this startup script and add ulimit call before starting Mongo DB daemon. This is still not the best solution to modify Mongo DB startup scripts.

The best way to deal with this problem would be changing limit defaults in file /etc/security/limits.conf or better adding specific configuration to /etc/security/limits.d See man pam_limits and man limits.conf for more information.

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.