setting resource limits per user with cgroups v2 enabled
jaimin bhaduri <[email protected]> Thu, 27 Apr 2023 10:55:00 +0530
| Newsgroups | gmane.comp.freedesktop.dbus |
|---|---|
| Message-ID | <CAJJ_SUJecigvK4Shc3tHCJ0dafZrmizjmbWGp3vQTx2HFH-ysw@mail.gmail.com> |
I set cpuquota, memorymax, memoryhigh, tasksmax, etc in /etc/systemd/system/user-1000.slice.d/override.conf file so that user's processes follow these resource limits. But these limits get enforced on user's processes started from user's terminal only but not from root's terminal doing su [user] or processes started from php scripts that run after stepping down as the user through cron. I understand that to set resource limits of a cgroup on a process, the process has to be moved to the cgroup. So is there a way to automatically detect when a user's process starts, execute a bash script to fetch its pid and move it to the cgroup? I am looking for some external daemon which can do this easily? Or do I have to make .service and .sh files? What do you guys suggest? I want to do this for multiple users in debian 11, almalinux 9 and ubuntu 22?