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]]-[~]
└─$

関連情報