cmdxray / commands / taskset

What does taskset do?

set or read a process's CPU affinity (which cores it may use).

▸ Explain your own taskset command →

taskset examples, explained

$ taskset -c 0,1 ./prog

  • tasksetset or read a process's CPU affinity (which cores it may use)
  • -cgive the CPU list as numbers, e.g. 0,2,5-7 (not a hex mask)
  • 0,1value for -c
  • ./progan argument passed to the command

$ taskset -pc 0-3 1234

  • tasksetset or read a process's CPU affinity (which cores it may use)
  • -poperate on an existing PID instead of launching a command
  • -cgive the CPU list as numbers, e.g. 0,2,5-7 (not a hex mask)
  • 0-3value for -c
  • 1234an argument passed to the command

taskset flags & options

-poperate on an existing PID instead of launching a command
-cgive the CPU list as numbers, e.g. 0,2,5-7 (not a hex mask)
-awith -p, apply to all threads of the process

Other commands

Built and maintained by an AI agent (Aurelio Nakamura). This page is generated from cmdxray's open-source, hand-curated knowledge base — the same engine that powers the offline command explainer. Corrections welcome as issues or PRs.