When the computer has enough CPU time to execute all the processes, there is no need to prioritize. But when it is necessary to start several processes in parallel, each of which uses all the available processor time, the nice utility can be very useful.
The nice command launches a program with a modified priority for the task scheduler. The word "nice" in English means, in particular, "polite". According to the etymology of this command, a process with a large nice value is more polite to other processes, allowing them to use more CPU time, since it itself has a lower priority (and, therefore, a greater “courtesy value” - niceness value).
The highest priority (and the lowest nice value) is −20. 19, or 20 is the lowest priority, but, on the other hand, it is the most polite processes.
To see the identifier and the nice value of the desired process in the system, you can use the ps axl command
An example of using the nice command is to run a resource-intensive task in the background, so that it runs, but frees up some processor time for other processes as soon as they become needed. Thus, we can, say, run OGG / MP3 encoding with a large nice value so that it occurs in the background, using not all the CPU time, but something that is not used by other processes (with a lower nice value — that is, with a higher priority).
To run a command with a certain priority, add “nice -n value_nice” to the left, or “nice --adjustment value_nice” (adjustment - adjustment, adjustment).
That is: nice -n value_nice command
If you need to change the priority of an already running process, you can use the renice command.renice -n value_nice process_id
The renice command displays the old and new process priority.
Now, knowing these commands, you can control the processes so that certain tasks are performed faster in the case when many processes use all the available processor time.