Controlling CPU usage for a service(systemd)

Controlling CPU usage for a service(systemd)

Content #

sudo SYSTEMD_EDITOR=vim systemctl edit --full --force cputest.service
sudo systemctl daemon-reload
sudo systemctl start cputest.service
sudo systemctl cat cputest
sudo systemctl set-property cputest.service CPUQuota=90%
sudo systemctl cat cputest
sudo SYSTEMD_EDITOR=vim systemctl edit --full --force cputest.service
cat /sys/fs/cgroup/cpu/system.slice/cputest.service/cpu.cfs_quota_us
90000

cputest.service文件的内容:

[Unit]
Description=CPU stress test service
[Service]
ExecStart=/usr/bin/stress-ng -c 4

From #