English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Linux nice command

Linux Command大全

Linux nice command executes programs with the changed priority, if no program is specified, it will print the current scheduling priority, and the default adjustment is 10, ranging from -20 (Highest priority) to 19(Lowest priority).

Usage Permissions: All users.

Syntax

nice [-n adjustment] [-adjustment] [--adjustment=adjustment] [--help] [--version] [command [arg...]]

Parameter Description:

  • -n adjustment, -adjustment, --adjustment=adjustment Both are to increase the original priority by adjustment
  • --help Display Help Messages
  • --version Display Version Information

Online Examples

Set Program Priority at Runtime

# vi & //Run in Background
[1] 15297
# nice vi & //Set Default Priority
[2] 15298
[1]+ Stopped         vi
# nice -n 19 vi & //Set Priority to19
[3] 15299
[2]+ Stopped         nice vi
# nice -n -20 vi & //Set Priority to -20
[4] 15300
[3]+ Stopped         nice -n 19 vi
# ps -l //Display Processes
F S  UID  PID PPID C PRI NI ADDR SZ WCHAN TTY     TIME CMD
4 S   0 15278 15212 0 80  0 - 1208 wait  pts/2  00:00:00 bash
0 T   0 15297 15278 0 80  0 - 2687 signal pts/2  00:00:00 vi
0 T   0 15298 15278 0 90 10 - 2687 signal pts/2  00:00:00 vi
0 T   0 15299 15278 1 99 19 - 2687 signal pts/2  00:00:00 vi
4 T   0 15300 15278 3 60 -20 - 2687 signal pts/2  00:00:00 vi
4 R   0 15301 15278 0 80  0 -  625 -   pts/2  00:00:00 ps
[4]+ Stopped         nice -n -20 vi

Increase the priority of ls 1 and execute

nice -n 1 ls

Increase the priority of ls 10 and execute

nice ls

Note:Priority (priority) is a parameter used by the operating system to decide CPU allocation, Linux uses 'round-robin(round-The CPU scheduling is done using Robin's algorithm, the higher the priority, the more CPU time it may obtain.

Linux Command大全