I am using CentOS 7 and I have several users registered in system (UIDs: 1000, 1001, 1002, etc)
I want to restrict memory consumption for each user using cgroup and systemd.
The following commands work pretty well but the user with UID=1000 must be logged in.
systemctl set-property user-1000.slice MemoryLimit=3000M
systemctl daemon-reload
If the user is not login I receive the following error message
Failed to set unit properties on user-1000.slice: Unit user-1000.slice is not loaded.
Imagine I have 20 users and I want to set up memory restrictions for them. Should I log in manually or write some workaround script to do it in order to run systemctl set-property
command for each user? Or some elegant and straightforward solution exists?