linux-command/command/nice.md

42 lines
925 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

nice
===
调整程序执行的优先权等级
## 补充说明
**nice命令** 用于调整进程调度优先级启动其他的程序。
### 语法
```shell
nice [选项] [命令 [参数]...]
```
### 选项
```shell
-n指定nice值整数-20最高~19最低
```
### 参数
指令及选项:需要运行的指令及其他选项。
### 实例
新建一个进程并设置优先级将当前目录下的documents目录打包但不希望tar占用太多CPU
```shell
nice -19 tar zcf pack.tar.gz documents
```
方法非常简单,即在原命令前加上`nice -19`。很多人可能有疑问了最低优先级不是19么那是因为这个“-19”中的“-”仅表示参数前缀所以如果希望将当前目录下的documents目录打包并且赋予tar进程最高的优先级就应该加上`nice --20`
```shell
nice --20 tar zcf pack.tar.gz documents
```