Long time ago I used cgmanager
to put all my browsers (Opera, Firefox, Chrome) in a single cgroup and set max RAM usage limit for that group.
However, modern systemd
really doesn't want other programs messing up with the cgroups so how to configure this with modern Ubuntu?
Basically I'm asking how to configure selected processes listed by systemctl status session-$XDG_SESSION_ID.scope
to be automatically moved by systemd to user defined group with special limits? For example, I'd like to define that if the process binary is
/usr/bin/firefox
or /opt/google/chrome/chrome
then it should be moved to my custom user cgroup called mybrowsers
.
I'm also looking for a generic solution that doesn't depend on desktop environment or window manager doing this (I know that modern Gnome should create some groups automatically). I guess I could write a program to monitor new processes and then move them using systemd API but I assume there must be a way to do this by systemd, right? And any option that depends on polling process list seems workaround at best.
And I'm looking for a solution that is fully user defined if at all possible. And I'm aware that this can be done via systemd-run
but that seems leaky solution because it's too easy to start a program the "wrong" way and then systemd-run
is skipped.