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?
2Hi, it sounds like you might be suffering from the x y problem here, it is sometimes worth looking back at what you want to achieve and not the attempted solution you tried as it seems that what you need is to run a program without slowing down your PC, not just to run something on one core. None the less, this is a very good question. +1– ValityJun 16, 2014 at 14:18
1related: unix.stackexchange.com/questions/23106/…– Ciro Santilli OurBigBook.comApr 25, 2018 at 9:13
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 --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).
2By the way, you could also try to just renice the "bad" processes, lowering their scheduling priority. Jun 16, 2014 at 8:21
@MatteoItalia I found that Ubuntu 13.10 and 14.04 ignore nice level by default. You have to add
kernel.sched_autogroup_enabled = 0to
/etc/sysctl.confto make it work. However I also found that 13.10 frequently kernel panic during boot, if autogroup is disabled.– kasperdJun 16, 2014 at 13:14
2What about child processes of the parent process? Do they inherit the core/cpu affinity of their parent process? Mar 12, 2017 at 10:47
Though another answer has already given the literal answer I would explore the possibility this is not being done the right way. Instead you should run a script which you do not want to slow down the computer (such as non interactive scripts) using the
To do this simply prefix the command you wish to run with nice, for example:
This will cause the program to be de-prioritized below other tasks and will not slow down your machine. I often use this technique when doing a long compile which would otherwise slow down my PC to a crawl, this has the advantage of allowing the program to use all cores when the machine is not busy but will quickly stop it using them when you run something else.
If I use a command like "nice open terminator" will terminator run with all CPU cores regardless? Jun 16, 2014 at 16:49
Oh, and by the way, If I move my mouse and nothing is opening will it use all CPU's? And how long does it take after I stop moving my mouse for it to utilize all CPU's? And can I use this with taskset? (Yeah, I'm a real noob with Linux.) Jun 16, 2014 at 16:59
@user245115 If you use the nice utility it is possible that terminator will use multiple CPU cores, however it will immediately stop using those cores if another program (not running with nice) wants to use them so you will not experience slowdown, however it will use them if they are otherwise completely free and unused. This should not be affected by mouse usage or any other interaction with the program. Jun 16, 2014 at 17:05
@user245115 It should also be possible to use this with taskset simply by writing
taskset nice open terminatorto use both. However that will be overkill as you will be using two different programs to both achieve the effect of reducing the resource usage of the program. Jun 16, 2014 at 17:05
@user245115 The moment you take any other action (like moving the mouse) terminator will be given less CPU time, this is effectively instant and as soon as you stop other activity it will use it again (also effectively instant) Jun 16, 2014 at 17:07