Forrest logo
back to the taskset tool

taskset:tldr:4cb0e

taskset: Get a running process' CPU affinity by PID.
$ taskset --pid --cpu-list ${pid}
try on your machine

The command "taskset --pid --cpu-list ${pid}" is used to assign a specific CPU or a set of CPUs to a running process with the given process ID (pid).

Here is a breakdown of the components in this command:

  • "taskset": It is a command-line utility in Linux used to manipulate CPU affinity, which determines the CPUs on which a process can run.

  • "--pid": This option is used to specify that the CPU affinity should be set for the process with the given pid.

  • "--cpu-list": This option is used to specify the CPUs to which the process should be bound. The CPU list can be a single CPU number or a comma-separated list of CPU numbers or a range of CPUs (e.g., 0,2,4-6).

  • "${pid}": This is a placeholder representing the actual process ID to which the command will be applied. It needs to be replaced with the desired process ID before executing the command.

In summary, this command is used to set the CPU affinity of a process identified by the given pid to run on specific CPUs specified in the cpu-list.

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