Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

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?

share|improve this question
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 '12 at 10:55
What OS are you running? – Patrick Feb 24 '12 at 13:10
up vote 3 down vote accepted

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

share|improve this answer

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

share|improve this answer

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.

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.