With the nice and renice commands, we can specify the priority of a program when it starts, or change the priority of a running process.

Options

nice Command Options

Here are some options for nice command:

Option Description
-n or ‑‑adjustment=N Replace the niceness (priority level) of the specified program with the number N.

renice Command Options

Here are some options for renice command:

Option Description
-n or ‑‑priority priority Replace the niceness (priority level) of the specified program with the number priority.
-g or ‑‑pgrp The process group ID(s) is/are specified.
-p or ‑‑pid The process ID(s) is/are specified.
-u or ‑‑user The username(s) or ID(s) is/are specified.

Examples

Run the Program With Specified Niceness in Terminal One

1
nice -n -5 top    # This is equivalent to nice --adjustment=-5 top
img

Adjust the Niceness of the Top Command in Terminal Two

1
2
# 17685 is the process ID of the running top command
renice -n -10 17685    # This is equivalent to renice --priority -10 17685
img

After adjusted the niceness, let’s look back at terminal one:

img

References NICE(1), RENICE(1)

Buy me a coffeeBuy me a coffee