Ubuntu – How to run a program with only one CPU core

cpu

I'm trying to run a bunch of scripts related to a gaming server in Terminator. The only problem is when I do this, Terminator detects all my CPU cores and the PC lags. Is there any way to start it up but trick it into thinking I only have 1 CPU core?

Best Answer

It is not terminator that is doing the "spreading" on all the CPU of a given process. Linux itself (the kernel) is doing this. A task (process) is scheduled as available to run on all CPUs by defaults; if it uses threads it can uses more than one CPU at a time.

To restrict a process to a specific CPU, you use the command taskset.

taskset --cpu-list 1,2 my_command 

This command forces my_command to run just on CPUs #1 or #2.

To learn more, type man taskset or search for "linux CPU affinity" (first hit here).

Related Question