3

I have a CentOS 7.4 system which has a number of users who access the system via SSH. I need a way to prevent them from consuming all CPU and memory of the system. For example, each user getting 1 CPU core or a "1/20th share" of CPU time is fine.

The closest I have is based on setting the CPUQuota property of each user slice after a user logs in. I did this but the settings have no effect. What am I missing?

  • /etc/systemd/user.conf had DefaultCPUAccounting=yes set then rebooted
  • Logged in as test user
  • systemctl set-property user-43045.slice CPUAccounting=yes CPUQuota=20%
  • As the user, in a shell within the cgroup (systemd-cgls): dd if=/dev/zero of=/dev/null bs=1024k

Still no limit to CPU usage. Is there any supported, not deprecated way to limit SSH users? Both the cgconfig+cgred method and the PAM method do not appear to work at all on CentOS 7.

EDIT #1 - and solution

After making the same change to /etc/systemd/system.conf the CPUQuota option now has an effect. So systemd requires tracking things in both system and user for some reason.

closed as off-topic by slm Jul 10 '18 at 3:00

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – slm
If this question can be reworded to fit the rules in the help center, please edit the question.

  • Per the OP: ... After making the same change to /etc/systemd/system.conf the CPUQuota option now has an effect. So systemd requires tracking things in both system and user for some reason. – slm Jul 10 '18 at 2:59

Browse other questions tagged or ask your own question.