How to change a processes priority


Every running process in Unix has a priority assigned to it.

You can change the process priority using nice and renice utility. The Nice command will launch a process with an user defined scheduling priority. The Renice command will modify the scheduling priority of a running process.

Linux Kernel schedules the process and allocates CPU time accordingly for each of them. But they can be adjusted

The process scheduling priority range is from -20 to 19. -20 being highest priority and 19 being the least priority

By default when a process starts, it gets the default priority of 0.

1. Display Nice Value of a Process

The current priority of a process can be displayed using ps command.
The “NI” column in the ps command output indicates the current nice value (i.e priority) of a process.

2. Launch a Program with Less Priority

Instead of launching the program with the default priority, you can use nice command to launch the process with a specific priority.
In this example, screen -dmS test yes is launched with a nice value of 10.

As you see below, this program is now launched with a nice value of 10, which means this will run at a lower priority when compared to other programs that are launched by default.

3. Launch a Program with High Priority

You can also launch a program with a higher priority. Negative nice value will increase the priority a the process. So, the value has to be specified with a — (two hyphens) in front of the nice command as shown below.

So, to pass nice value of -18, you’ll add two hyphens in front of 18. To pass nice value of -6, you’ll add two hyphens in front of 6.

5. Change the Priority of a Running Process

The priority of an already running process can be changed using renice command. In this example, we'll adjust the priority of the previous example. By specifying the process with the -p option:


Have more questions? Submit a request