nice (调整程序运行的优先级)

秃噜豆儿 发表于 2020-07-23 15:51
浏览次数:
在手机上阅读

在Unix-like的操作系统上,nice命令以修改的调度优先级运行命令。 本文介绍nice的GNU/Linux版本。

查看英文版

目录

1 nice 运行系统环境

2 nice 描述

3 nice 语法

4 nice 选项

5 nice 示例

nice 运行系统环境

Unix&Linux

nice 描述

nice使用调整后的“niceness”运行命令命令,这会影响进程调度。精度值较低的进程将获得更高的优先级和更多的CPU时间。具有较高niceness值的进程(“更好的”进程)将被赋予更低的优先级和更少的CPU时间,从而为要求更高的进程释放资源。
精确性值的范围为-20(对过程最有利)到19(对过程最不利)。
如果没有命令,nice将打印当前niceness级别。
nice runs command COMMAND with an adjusted "niceness", which affects process scheduling. A process with a lower niceness value is given higher priority and more CPU time. A process with a higher niceness value (a "nicer" process) is given a lower priority and less CPU time, freeing up resources for processes that are more demanding.
Niceness values range from -20 (most favorable to the process) to 19 (least favorable to the process).
With no COMMAND, nice prints the current niceness level.

查看英文版

查看中文版

nice 语法

nice [OPTION] [COMMAND[ARG]...]
nice [OPTION] [COMMAND[ARG]...]

查看英文版

查看中文版

nice 选项

-nN, --adjustment=N 将整数N加到niceness上(默认值为10)。
--help 显示帮助消息并退出。
--version 输出版本信息并退出。
-nN--adjustment=N Add integer N to the niceness (default is 10).
--help Display a help message and exit.
--version Output version information and exit.

查看英文版

查看中文版

nice 示例

nice

显示新进程的默认niceness级别;通常为零,因此输出可能如下所示:

0

nice -n13 pico myfile.txt

在上运行pico命令我的文件.txt精确增量为13。因为我们已经看到默认的niceness级别是0,所以运行pico时niceness级别为0加13,即13。因此,pico将能够使用比任何运行在niceness级别大于14的进程更高的CPU资源,但是它的优先级低于值小于14的进程。
实际上,这告诉系统将pico视为低优先级进程,而不是最低优先级进程。

nice

Displays the default niceness level of new processes; this is commonly zero, so the output would probably look like this:

0

nice -n13 pico myfile.txt

Runs the pico command on myfile.txt with an niceness increment of 13. Since we already saw that the default niceness level was zero, this runs pico with a niceness level of zero plus 13, which is 13. As a result, pico will be able to use CPU resources with a higher priority than any process running with a niceness level greater than 14, but will have a lower priority than processes with a value less than 14.

Effectively, this tells the system to treat pico as a low-priority process, but not the lowest.

查看英文版

查看中文版

其他命令行

newalias | newform | newgrp | niscat | nischmod | nischown | nischttl | nisdefaults | nl | nohup | nroff | nc | nisgrep | nispasswd | nistbladm |

如此好文,分享给朋友
发表评论
验证码:
评论列表
共0条