taskset
process managementLinux
The taskset command is one of the most frequently used commands in Linux/Unix-like operating systems. taskset Set or retrieve a process's CPU affinity
Quick Reference
Command Name:
taskset
Category:
process management
Platform:
Linux
Basic Usage:
taskset [options] [arguments]
Common Use Cases
Syntax
taskset [options] mask command [argument...] taskset [options] -p [mask] pid
Options
Option | Description |
---|---|
-a, --all-tasks |
Set or retrieve the CPU affinity of all tasks (threads) of the specified process |
-c, --cpu-list |
Specify CPUs by a comma-separated list or range of CPU numbers instead of a mask |
-p, --pid |
Operate on an existing process instead of launching a new command |
-h, --help |
Display help information and exit |
-V, --version |
Display version information and exit |
Examples
How to Use These Examples
The examples below show common ways to use the taskset
command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.
# Basic Examples Basic
# Start a new process with CPU affinity set to CPU 0
taskset 0x1 command arg1 arg2