Set memory limit on service

Apply cgroup limits without editing unit file

systemctl set-property myapp.service MemoryMax=512M CPUQuota=50%

tool
systemd26 commands
tags
systemdperformance

More systemd commands

  • systemctl status myapp.service | grep -E 'Memory:|CPU:|Tasks:'

    Current memory, CPU, and task counts from cgroup

  • systemctl list-units --type=socket --all

    All socket-activated units and their state

  • systemctl mask snapd.service

    Prevent a service from being started by anything

  • systemctl show myapp.service -p Environment

    Print environment variables injected into the service

  • systemd-analyze critical-chain <unit>

    Show the serialized dependency chain that actually delays boot; more honest than blame

all 26 systemd commands