New answers tagged limit
With the comment from @Mark Plotnick, I finally figured out the reason ls -l "/proc/$(pidof node)/exe" returns lrwxrwxrwx 1 antony antony 0 Aug 27 13:04 /proc/4414/exe -> /usr/bin/nodejs So instead of node, I should have used nodejs The following command works cpulimit -l 50 -e nodejs Update: this is actually not a bullet-proof solution. Yes, ...
cpulimit is known not to work well in some cases. Sometimes it works quite well (on simple single threaded apps) and other times (mostly mutli-threaded or muti-process) it doesn't work. Technically speaking, there are two issues that could cause cpulimit to not limit. First is that the program your trying to run spawns a thread or process in such a way ...
While it can be an abuse for memory, it isn't for CPU: when a CPU is idle, a running process (by "running", I mean that the process isn't waiting for I/O or something else) will take 100% CPU time by default. And there's no reason to enforce a limit. Now, you can set up priorities thanks to nice. If you want them to apply to all processes for a given user, ...
Did you look at cgroups? There is some information on the Arch Wiki about them. Read the section about cpu.shares, it looks like it's doing what you need, and they can operate on a user-level, so you can limit all user processes at once.
For memory, what you are looking for is ulimit -v. Note that ulimit is inherited by child processes, so if you apply it to the login shell of the user at the time of login, it applies to all his processes. If your users all use bash as login shell, putting the following line in /etc/profile should cause all user processes to have a hard limit of 1 gigabyte ...
Since you are stating that cpulimit would not be practical in your case, then I suggest you look at nice, renice, and taskset, which may come close to what you want to achieve, although taskset allows to set a processes’s CPU affinity, so it might be not immediately helpful in your case.
Top 50 recent answers are included