--nice 与 cp 一起为 cp 提供更多处理器优先级?

Aha*_*Aha 4 linux

如何在 linux 中将 --nice=-10 与 cp 命令一起使用?

以下是我尝试该选项时的示例,它给出了错误无法识别的选项 EX- 错误:

cp --nice=-20 -r dir1 /d/
cp: unrecognized option `--nice=-20'
Try `cp --help' for more information.
Run Code Online (Sandbox Code Playgroud)

Tha*_*Guy 5

nice本身就是一个命令,它不是cp命令的一个选项。

来自man nice

NAME
       nice - run a program with modified scheduling priority

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

DESCRIPTION
       Run COMMAND with an adjusted niceness, which affects process scheduling.
       With no COMMAND, print the current niceness.  Nicenesses range from -20
       (most favorable scheduling) to 19 (least favorable).

       -n, --adjustment=N
              add integer N to the niceness (default 10)
Run Code Online (Sandbox Code Playgroud)

所以为了你的目的,你会使用这个:

nice -n -20 cp -r dir1 /d/
Run Code Online (Sandbox Code Playgroud)


And*_*man 5

随着cp你可能会更I / O限制比CPU限制。要调整 I/O 优先级,您可以使用ionice命令 - 请参阅man ionice。例如,要在所有尽力而为进程中获得最高优先级的“尽力而为”优先级,请运行

ionice -c 2 -n 0 cp -r dir1 /d/
Run Code Online (Sandbox Code Playgroud)

您还可以将其与nice调整 CPU 和 I/O 优先级结合使用:

ionice -c 2 -n 0 nice -n -20 cp -r dir1 /d/
Run Code Online (Sandbox Code Playgroud)