Priority Queue
Priority Queue on Linux Servers¶
We can set priorities for Linux commands using nice and renice commands and by setting the processes PR (priority value)
There is a more in depth guide for niceness HERE.
Why?¶
We will sometimes need to update the priority queue for long-running processes that are time sensitive or processes we would prefer to have finish faster.
Nice Values¶
Nice¶
nice
is a number range from -20 to +19, the lower the higher priority, that determines a
processes' priority.
This number is set to 0 by default for new processes and all processes
with the same priority are grouped together and run sequentially.
You can run a command while setting the nice
command.
nice -n niceness-value command args
nice -n -20 bin/magento s:s:d -f -j4 en_US en_GB
Renice¶
We can also adjust niceness value of a pre queued process using the renice
command.
This can be done using either the process id (PID) or using the user id
- Using PID
renice -n -20 -p 1000
- Using UID
renice -n -20 -u root
Setting default values¶
Default nice values can be set in /etc/security/limits.conf
The syntax is:
#<domain> <type> <item> <value>
<username> <hard|soft> priority <nice value>
ec hard priority -20
Addendum¶
You can get more information on these functions using man
.
man nice
man renice
Using HTOP¶
If when checking processes using HTOP you think that a process is running slowly, you can dynamically update the nice value using HTOP.
To increase the priority you can use F7 to minus the nice value.