<div dir="ltr">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.<div>I understand that to set resource limits of a cgroup on a process, the process has to be moved to the cgroup.</div><div>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?</div><div>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?</div><div>I want to do this for multiple users in debian 11, almalinux 9 and ubuntu 22?</div></div>