systemd-run

Limit memory and CPU usage of test commands via systemd-run.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/fasterthanlime/_claude --skill systemd-run
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: systemd-run
Source: https://github.com/fasterthanlime/_claude/tree/main/skills/systemd-run
Command: npx skills add https://github.com/fasterthanlime/_claude --skill systemd-run

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Run commands with strict memory and CPU limits using systemd's cgroup integration to reproduce limits, prevent runaway tests, and simulate CI environments.

Core Features & Use Cases

  • Memory Limits: MemoryMax, MemorySwapMax to cap RAM and swap.
  • CPU Quotas: CPUQuota and related properties to throttle CPU usage.
  • Combined Limits: Apply multiple constraints for realistic test environments.
  • Wrapper Integration: Use with Nextest wrapper scripts for instrumentation.

Quick Start

MEMORY_LIMIT=512M cargo nextest run --profile limited

Frequently Asked Questions about systemd-run

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I limit memory and CPU usage when running tests?

Memory and CPU limits for tests are enforced using systemd-run, which applies cgroup constraints on Linux. Set MemoryMax to cap RAM, CPUQuota to throttle CPU, and use environment variables like MEMORY_LIMIT with your test runner to reproduce OOM conditions and prevent runaway tests in CI-like environments.

Can I use systemd-run to simulate CI resource constraints locally?

Yes, systemd-run simulates CI environments by enforcing hard limits such as MemoryMax and CPUQuota, soft limits like MemoryHigh, and I/O controls including IOWeight and IOReadBandwidthMax. This reproduces resource constraints across test suites and builds on any Linux system with systemd.

How do I integrate resource limits with Nextest?

Integrate resource limits with Nextest using wrapper scripts and the MEMORY_LIMIT environment variable. Run `MEMORY_LIMIT=512M cargo nextest run --profile limited` to confine tests with systemd cgroup enforcement, enabling end-to-end test confinement and status monitoring.

What resource constraints can systemd-run enforce?

systemd-run enforces hard memory limits via MemoryMax and MemorySwapMax, CPU throttling through CPUQuota, soft memory limits with MemoryHigh, and I/O controls including IOWeight, IOReadBandwidthMax, and IOWriteBandwidthMax. RuntimeMaxSec sets execution time limits for complete test confinement.

Do I need systemd to run tests with memory and CPU limits?

Yes, systemd-run requires Linux with systemd and cgroup integration. It cannot be used on systems without systemd support, making it a Linux-specific approach to reproducing OOM conditions and enforcing resource constraints during testing.

Why use systemd-run instead of other resource limiting tools?

systemd-run provides integrated cgroup enforcement across multiple constraint types—memory, CPU, I/O, and time—in a single invocation. It works natively with Linux test workflows and CI environments, supporting wrapper scripts and test runners like Nextest for transparent resource confinement without external tools.