Renice 命令

顾名思义, renice 是用来重新设置进程优先级的.

语法:

renice [-20到20的优先级] -p [PID]

降低一个进程的优先级

$ ps axl | grep nice-test
0 509 13245 13216 30 10 5244 968 wait SN pts/1 0:00 /bin/bash ./nice-test.sh

然后:

$ renice 16 -p 13245
13245: old priority 10, new priority 16

$ ps axl | grep nice-test
0 509 13245 13216 36 16 5244 968 wait SN pts/1 0:00 /bin/bash ./nice-test.sh

优先级变成16了, 降低了.

增加一个进程的优先级

$ ps axl | grep nice-test
0 509 13254 13216 30 10 4412 968 wait SN pts/1 0:00 /bin/bash ./nice-test.sh

然后增加它的优先级(以普通用户的身份):

$ renice 5 -p 13254
renice: 13254: setpriority: Permission denied
Login as root to increase the priority of a running process

报错了, 说我们权限不足, 要用root才行.

$ su -
# renice 5 -p 13254
13254: old priority 10, new priority 5

# ps axl | grep nice-test
0 509 13254 13216 25 5 4412 968 wait SN pts/1 0:00 /bin/bash ./nice-test.sh

这样就可以了.

results matching ""

    No results matching ""