Often feel that the system resources are not enough, a machine ran on less than 3 more important services, but every day we have to do a backup compression, such as processing, the network for a long time transmission, which is very influential in this is not enough to use the system resources;
At this point, we can limit some of the less important things, such as copy/Backup/synchronization, to one CPU or one core of a multicore CPU, although this is not necessarily the most efficient approach, but it can be used to the greatest extent possible with efficient resources, reducing the CPU resources of less important processes ;
Taskset can help us do the work, and the operation is very simple;
The tool system is installed by default, RPM package name Util-linux
With an example, a shell script that consumes CPU resources, using a previously written script that consumes CPU, exhausts the resources of 4 CPUs on a 16-CPU machine:
Use the top command to see the effect of 4 CPUs running full:
You can now use the Taskset command to adjust the CPU used by these processes:
TASKSET-CP 1 25718taskset-cp 3 25720taskset-cp 5 25722taskset-cp 7 25724
Look at the effect in top:
Haha, CPU usage has been provisioned, and we can make a process use only a few of these CPUs:
TASKSET-CP 25718
More detailed information can be viewed with the man taskset.
Use the Taskset command to limit the CPU of a process