I have a command to run (in this case is a php5 script) and I would like to know if there is something to run this command and select the core to be runed.

What I want to do is to run 1 command per each core to use the multiple cores of my server.

Any idea? Or I have to rewrite the script in other languages with multicore support and develop the core control directly in the script?

  • If you're on Linux and you really want to run something on a specific core, numactl will do this. Otherwise, as below, run 2 copies at once and they'll be assigned to different cores for you.
    – pjc50
    Feb 24, 2012 at 10:55
  • What OS are you running?
    – phemmer
    Feb 24, 2012 at 13:10

3 Answers 3


The command to run or assign a specific command to a particular core is taskset.

Embed it in your startup script or use from the command line like:

taskset -c 0,5 command_name -c is a list of one or more CPUs to run the command on; in this case, core 0 and 5.

You can also modify the core assignment of a running process by specifying a PID with taskset.

But you may also want to see: Assigning Processes to CPU Cores


Your kernels scheduler will do this just fine all by itself and doesn't need a user to do his work.


What I want to do is to run 1 command per each core to use the multiple cores of my server.

Multi core for beginners: the system scheduler takes care of that.

StartX instances, with X being the number of hardware threadyyou ahve (cores, or real cores x2 for intel with hyperthreading.

If your program uses only one core, nothign you do will optimize it, given that you use an OS that is NUMA aware on a NUMA archtiecture.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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