Forrest logo
back to the taskset tool

taskset:tldr:3a9de

taskset: Start a new process with affinity for a single CPU.
$ taskset --cpu-list ${cpu_id} ${command}
try on your machine

The taskset command in Linux is used to set or retrieve the CPU affinity of a running process. CPU affinity refers to the set of CPU cores on which a process is allowed to run.

The command "taskset --cpu-list ${cpu_id} ${command}" sets the CPU affinity of a process for a specific CPU or list of CPUs identified by ${cpu_id}. Here's a breakdown:

  • ${cpu_id}: This represents the CPU or list of CPUs to which the process should be bound. It can take various forms, such as a single CPU core number (e.g., 0), a range of cores (e.g., 0-3), or a comma-separated list of CPUs (e.g., 0,2,4).

  • ${command}: This represents the executable or command that you want to run with the specified CPU affinity.

So, when you run the command "taskset --cpu-list ${cpu_id} ${command}", it will execute ${command} with the CPU affinity set to the specified ${cpu_id}, ensuring the process runs exclusively on the specified CPU(s).

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 taskset tool