systemd-run이 리소스 제한이 있는 임시 명령에 대한 임시 cgroup을 생성할 수 있습니까?

systemd-run이 리소스 제한이 있는 임시 명령에 대한 임시 cgroup을 생성할 수 있습니까?

반대 작업 과 유사하게 cgroup생성된 임시 명령으로 리소스 소비를 제한하고 싶지만 이것이 의미가 있는지 잘 모르겠습니다.systemd-runcgcreate

제대로 시도하고 있는지 확인하고 싶습니다. 모두 감사합니다!

┌──[[email protected]]-[~]
└─$ systemd-run -p  MemoryLimit=5M  -p CPUShares=100 --unit=sleep-50 --slice=test sleep 50
Running as unit sleep-50.service.
┌──[[email protected]]-[~]
└─$ systemctl status sleep-50.service
● sleep-50.service - /usr/bin/sleep 50
   Loaded: loaded (/run/systemd/system/sleep-50.service; static; vendor preset: disabled)
  Drop-In: /run/systemd/system/sleep-50.service.d
           └─50-CPUShares.conf, 50-Description.conf, 50-ExecStart.conf, 50-MemoryLimit.conf, 50-Slice.conf
   Active: active (running) since 六 2022-10-29 01:29:29 CST; 10s ago
 Main PID: 33234 (sleep)
   Memory: 92.0K (limit: 5.0M)
   CGroup: /test.slice/sleep-50.service
           └─33234 /usr/bin/sleep 50

10月 29 01:29:29 liruilongs.github.io systemd[1]: Started /usr/bin/sleep 50.
┌──[[email protected]]-[~]
└─$ systemctl cat sleep-50.service
# /run/systemd/system/sleep-50.service
# Transient stub

# /run/systemd/system/sleep-50.service.d/50-CPUShares.conf
[Service]
CPUShares=100
# /run/systemd/system/sleep-50.service.d/50-Description.conf
[Unit]
Description=/usr/bin/sleep 50
# /run/systemd/system/sleep-50.service.d/50-ExecStart.conf
[Service]
ExecStart=
ExecStart=@/usr/bin/sleep "/usr/bin/sleep" "50"
# /run/systemd/system/sleep-50.service.d/50-MemoryLimit.conf
[Service]
MemoryLimit=5242880
# /run/systemd/system/sleep-50.service.d/50-Slice.conf
[Service]
Slice=test.slice
┌──[[email protected]]-[~]
└─$ systemctl status sleep-50.service
Unit sleep-50.service could not be found.
┌──[[email protected]]-[~]
└─$

관련 정보