Pin a process to CPU cores with taskset
Restrict a noisy or performance-critical process to chosen cores with CPU affinity.
01Command
$ taskset -cp 0-3 1234502What it does
taskset sets the CPU affinity mask of a process, deciding which cores the scheduler may run it on. Keeping a compiler or game server on fixed cores reduces cache thrashing and leaves other cores free for your desktop. -cp prints and then sets the affinity of an existing PID, and -a includes all threads of the process.
03Risk
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- taskset(1) — Arch Manual PagesEvidence: Describes taskset as setting or retrieving a process CPU affinity, with -c/--cpu-list and -p/--pid usage shown.
- taskset(1) — Debian bookwormEvidence: Documents taskset [options] -p [mask] pid with --pid, --cpu-list and --all-tasks options for setting CPU affinity of running processes.
Last verified: 2026-09-19 · Category: System & Settings
06Related solutions
Launch an interactive process viewer with color meters for CPU cores, memory, and swap, plus search, sort, and kill controls.
Show every TCP and UDP socket in listening state with the owning process name and PID — the modern replacement for netstat.
Show every systemd unit currently in a failed state, so you can inspect and restart whatever broke.