> For the complete documentation index, see [llms.txt](https://linux-in-action.gitbook.io/project/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://linux-in-action.gitbook.io/project/ren-wu-tiao-du/nice.md).

# nice 命令

`nice` 命令允许你设置命令启动时的调度优先级。要让命令以更低的优先级运行，只要用 `nice` 的 `-n` 命令行来指定新的优先级级别。

`nice` 命令阻止普通系统用户来提高命令的优先级。注意，指定的作业的确运行了，但是试图使用 `nice` 命令提高其优先级的操作却失败了。

> `nice` 命令的 `-n` 选项并不是必须的，只需要在破折号后面跟上优先级就行了。

## 使用实例

```bash
# 调整命令优先级为 10，同时以后台形式运行
$ nice -n 10 ./test4.sh > test4.out &
[1] 4973
$
# 打印出进程谦让度 NI
$ ps -p 4973 -o pid,ppid,ni,cmd
PID  PPID  NI CMD  4973  4721  10 /bin/bash ./test4.sh
```
