Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Let's say I have a quad-core box and four identical processes, each with ten threads. Is it possible, in Linux, to say that Process A is only allowed to run on CPU 0, Process B is only allowed to run on CPU 1, etc?

share|improve this question
taskset <affinity mask> -p <process>


taskset 1 -p 12345

to set process 12345 to use only processor/core 1

The bitmask can be a list (i.e. 1,3,4 to use cores 1 3 and 4 of a 4+ core system) or a bitmask in hex (0x0000000D the 1,3,4, 0x00000001 for just core 1)

taskset is usually in a package called shedutils.

Edit: almost forgot... If you want to set the affinity of a new command instead of change it for an existing process, use:

taskset <mask> <program> [<arg1>]...[<argN>]
share|improve this answer

taskset (util-linux 2.13-pre7) usage: taskset [options] [mask | cpu-list] [pid | cmd [args...]] set or get the affinity of a process

-p, --pid operate on existing given pid -c, --cpu-list display and specify cpus in list format -h, --help display this help -v, --version output version information

The default behavior is to run a new command: taskset 03 sshd -b 1024 You can retrieve the mask of an existing task: taskset -p 700 Or set it: taskset -p 03 700 List format uses a comma-separated list instead of a mask: taskset -pc 0,3,7-11 700 Ranges in list format can take a stride argument: e.g. 0-31:2 is equivalent to mask 0x55555555

you can alway optimize you server as u r need

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.