We will look at setting and changing process priorities in this section. We will now look at the renice
and nice
commands.
We saw in the earlier section that processes have a priority and nice value associated with them. The top
command screen shows the nice value under NI
column. You can change the priority of an already running process using the renice
command. This will change the CPU resource cycles that the process uses. Here's the syntax to change the priority of an already running process:
renice +5 1555
If you are running this command as a normal user, the values you can assign are 0
to 20
. Only root user can set a negative nice value. Lesser the number, higher the priority. But be very careful while setting a negative value to any process, as it may affect your Linux system seriously and it might then be impossible for you to use the keyboard or SSH into the system. By default, the kernel attributes almost all processes with a nice value of 0.