nice
Commandnice
The nice
command is used to run a command with modified scheduling priority. By default, processes in Linux run with a nice value of 0, which represents normal priority. The nice
command allows users to lower (increase the nice value) or raise (decrease the nice value) the priority of a process.
nice [OPTION] [COMMAND [ARGUMENTS]]
nice
-n
n (Nice Value)Set the nice value to n, which can range from -20 (highest priority) to 19 (lowest priority):
nice -n n [COMMAND]
--help
Display help information for the command:
nice --help
--version
Display the version information of the command:
nice --version
nice
Commandnice sleep 10
This command runs the sleep
command with the default nice value (0), delaying for 10 seconds.
nice -n 10 sleep 10
This command runs the sleep
command with a nice value of 10, reducing its priority.
nice -n -5 sleep 10
This command runs the sleep
command with a nice value of -5, increasing its priority.
The nice value can be set from -20 to 19:
Setting a higher nice value (e.g., 10) means the process will yield CPU time to others, while a lower nice value (e.g., -5) means it will prioritize this process over others.
Option | Description |
---|---|
-n n |
Set the nice value to n (from -20 to 19). |
--help |
Display help information for the command. |
--version |
Display the version information of the command. |