systemctl set-property user-1009.slice CPUQuota=50% Failed to set unit properties on user-1009.slice: Unit user-1009.slice is not loaded

0

I'm trying to set per-user limits on processes, most of them are run with sudo --user. Why do user-1001 and user-1008 on my system have the slice files, but I can't get it on 1009?

# systemctl set-property user-1009.slice CPUQuota=50%
Failed to set unit properties on user-1009.slice: Unit user-1009.slice is not loaded.

# systemctl status user-1009.slice
● user-1009.slice
   Loaded: loaded
   Active: inactive (dead)

I tried manually creating the file

# touch /etc/systemd/system/user-1009.slice

# systemctl status user-1009.slice
● user-1009.slice
   Loaded: masked (/etc/systemd/system/user-1009.slice; masked; vendor preset: disabled)
   Active: inactive (dead)

# systemctl set-property user-1009.slice CPUQuota=50%
Failed to set unit properties on user-1009.slice: Unit user-1009.slice is not loaded.

Also this doesn't make sense to me, the testprocess (PID 26668) shows in ps -U 1009, but it's running under the slice for user-1008 (because user-1008 used sudo to run it?)

# ps -U 1009 ; systemctl status user-1008.slice
  PID TTY          TIME CMD
15727 pts/1    00:00:00 bash
26668 ?        00:00:00 testprocess
● user-1008.slice - User Slice of testuser
   Loaded: loaded (/run/systemd/system/user-1008.slice; static; vendor preset: disabled)
  Drop-In: /run/systemd/system/user-1008.slice.d
           └─50-After-systemd-logind\x2eservice.conf, 50-After-systemd-user-sessions\x2eservice.conf, 50-Description.conf, 50-TasksMax.conf
   Active: active since Thu 2018-08-30 19:35:01 EDT; 2 days ago
   CGroup: /user.slice/user-1008.slice
           └─session-1801668.scope
             └─26668 ./testprocess

Searching around, all I could find is people saying to login as the user to fix this, but obviously the user has processes open. And I tried using su - user1009 in another terminal, but that didn't seem to help

die4ever2005

Posted 2018-09-02T03:54:12.163

Reputation: 1

Answers

0

Just in case someone else needs a solution, instead of using just sudo, sudo systemd-run worked for me

$ sudo systemd-run --uid=1009 --slice=user-1009 sleep 10

# ps -U 1009 ; systemctl status user-1009.slice

PID TTY TIME CMD

20199 ? 00:00:00 sleep

● user-1009.slice

Loaded: loaded

Active: active since Sun 2018-09-02 01:46:57 EDT; 2s ago

CGroup: /user.slice/user-1009.slice

      └─run-20198.service

        └─20199 /bin/sleep 10

https://www.reddit.com/r/linuxquestions/comments/9c9dka/issue_with_systemctl_setproperty_user1009slice

die4ever2005

Posted 2018-09-02T03:54:12.163

Reputation: 1