Score:1

How to configure systemd to put all my browsers in a single cgroup

cn flag

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.

cn flag
In case you don't mind working behind systemd these articles may help: https://www.lesbonscomptes.com/recoll/faqsandhowtos/cgroups_instructions.html and https://raymii.org/s/articles/Limit_specific_process_memory_on_desktop_linux_with_cgroups.html
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.