Forrest logo
back to the systemd-run tool

systemd-run:tldr:7a673

systemd-run: Set properties (e.g. CPUQuota, MemoryMax) of the process and wait until it exits.
$ systemd-run --property MemoryMax=${memory_in_bytes} --property CPUQuota=${percentage_of_CPU_time}% --wait ${command}
try on your machine

The command systemd-run is a utility provided by the systemd init system in Linux. It allows you to run a command as a transient service within the systemd manager.

Here's the breakdown of the command you provided:

systemd-run: This is the main command that starts a new transient service with the specified properties.

--property MemoryMax=${memory_in_bytes}: This flag sets the maximum memory limit for the service in bytes. ${memory_in_bytes} should be replaced with the desired value.

--property CPUQuota=${percentage_of_CPU_time}%: This flag sets the maximum CPU usage limit for the service as a percentage. ${percentage_of_CPU_time} should be replaced with the desired percentage value.

--wait: This flag makes the systemd-run command wait for the command to finish before exiting, allowing you to see its output.

${command}: This placeholder represents the actual command you want to run as a transient service. Replace ${command} with the desired command.

So, when you execute this command, systemd-run creates a new service with specified memory and CPU limits, runs the provided ${command} within that service, and waits for the command to complete. The output of the command will be displayed, and then the systemd-run command will exit.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the systemd-run tool