首页·终端命令

renice

进程与系统

用法

renice -n <priority> -p <pid>

修改已经在运行的进程的优先级;普通用户只能把它调得更谦让,想调回来需要 root。

常用选项

选项含义
-n <value>The new niceness, from 19 (nicest) to -20 (greediest).
-p <pid>Apply it to a process ID.
-u <user>Apply it to all of a user's processes.
-g <pgid>Apply it to a process group.

示例

renice -n 10 -p 1234

Make a running job nicer so it stops hogging the CPU.

sudo renice -n -5 -p $(pgrep -x mysqld)

Give the database more priority than everything else.

看什么在跑、什么在吃机器。先弄清是什么,再决定杀不杀。

怎么看

  • 方括号 [ ] 表示这部分可以不写。
  • 省略号 … 表示可以写多个。
  • 选项区分大小写——有些命令里 -r 和 -R 不是一回事。

常见问题

Q. renice 是做什么的?

修改已经在运行的进程的优先级;普通用户只能把它调得更谦让,想调回来需要 root。

Q. 怎么写?

renice -n <priority> -p <pid> —— 方括号表示可以省略的部分。

Q. 值得记的选项有几个?

这里列了 4 个,完整列表在 man renice。这条命令属于进程与系统。

相关命令

man 手册: man renice