Latest web development tutorials

Linux nice command

Linux command Daquan Linux command Daquan

Linux nice command to change over the priority order to execute the program, if the program is not specified, print the current scheduling priority order, a default adjustment is 10, ranging from -20 (highest priority order) to 19 (lowest priority order ).

Access: All users.

grammar

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

Parameter Description:

  • -n adjustment, -adjustment, --adjustment = adjustment are all the original Priority increase adjustment
  • --help show help message
  • --version Display version information

Examples

Priority setup runtime

# vi & //后台运行
[1] 15297
# nice vi & //设置默认优先级
[2] 15298

[1]+ Stopped         vi
# nice -n 19 vi & //设置优先级为19
[3] 15299

[2]+ Stopped         nice vi
# nice -n -20 vi & //设置优先级为 -20
[4] 15300

[3]+ Stopped         nice -n 19 vi
# ps -l //显示进程
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

Priority will be incremented by one and execute ls

nice -n 1 ls

The priority order plus 10 ls and executed

nice ls

Note: Priority (priority) for the operating system used to determine the parameters of CPU allocation, Linux use "turn (round-robin)" CPU scheduling algorithms do, the higher the priority order, CPU time might get it more.

Linux command Daquan Linux command Daquan