Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I was reading this answer to a question on setting limits for processes by using cgroups. The sample given sets limits for a process (in the example, sshd). In the answer, the PID of the process is set manually. This would be unacceptable for my purposes, I would like that processes started from a given application to always have the limits set, no matter when they are started nor limited by how many such processes are started.

Perhaps it is unclear from the example how that would happen, so a clear explanation or link to one would also be welcome. The example in the kernel cgroups.txt seems to use the same model as already given above.

share|improve this question

The easiest way is using systemd which may be responsible for your sshd anyway (depending on the distribution). You can easily configure the limits in the sshd unit file. systemd puts all services in separate cgroups anyway.

Without systemd the easiest solution is probably a modification to the sshd start script (pay attention that it's not overwritten by an update; it may be a good idea to copy it to a different name and disable the original script).

share|improve this answer
There is a troublesome app that limits would be great to clean up, that is not sshd. It is just that sshd was used in the example. Presumably, you can apply cgroups to any process. A script might end up being the easiest solution. It looked like cgroups would have been a good answer, though. – casualunixer Mar 1 '14 at 19:00
@casualunixer You just have to write a unit file for your app. You can configure is so that it is startet automatically on boot or just manually. – Hauke Laging Mar 1 '14 at 19:05
@laging, if you could give an example unit file in an answer, or pointer for documentation to one similarly, that would be appreciated. – casualunixer May 11 '14 at 18:05
@casualunixer It's exactly where one would expect it: man systemd leads to man 5 systemd.unit leads to man 5 systemd.service. On my system the SSH file is /usr/lib/systemd/system/sshd.service. – Hauke Laging May 11 '14 at 19:35
Ah, given I do not have systemd installed, even though that is the topic of this answer, it was not immediately obvious. – casualunixer May 13 '14 at 2:09

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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