Quick Linux Tip #22:
Try: systemd-run --scope -p CPUQuota=25% -p MemoryMax=500M ./heavy_script.sh
Info: systemd-run creates a transient cgroup with resource limits. Any process launched inside respects those limits. Great for testing or running untrusted code.
Examples:
- $ systemd-run --scope -p CPUQuota=50% stress --cpu 8
- $ systemd-run --user -p MemoryMax=1G firefox
- $ systemd-run --scope -p IOWeight=10 rsync -av /src /dst
Note: No installation needed on modern systems. Cleaner than cgcreate. Use --user for user services. IOWeight controls disk I/O priority.
Leave a Reply