nice -n 10:以低优先级启动命令
用更高的 nice 值启动命令,让它主动把 CPU 让给交互式程序。
运行 nice -n 10 ./backup-script.sh,以 nice 值 10 启动任务,使其成为低优先级任务;可再加 & 放入后台运行。
01命令
命令
$ nice -n 10 ./backup-script.sh02作用说明
nice 值的范围是 -20(最高优先级)到 19(最低),默认从父 shell 继承(通常为 0)。nice -n 10 会以 nice 值 10 启动命令,调度器会先满足普通优先级的任务,再把 CPU 分给它。省略 -n 时,直接写 nice <命令> 同样使用默认调整值 10。负值(提高优先级)需要 root 权限,普通用户只能降低优先级;如果进程已经在运行,请改用 renice。
03风险
04撤销
✓无需撤销——该命令不会改变持久状态。
05来源
- Ubuntu Manpage: nice - invoke a utility with an altered nice value依据: "nice [ -n increment ] utility [argument...]" — the -n option takes an increment that is added to the current niceness; unprivileged users can only raise (positive) niceness.
- nice - run a program with modified scheduling priority依据: "nice - run a program with modified scheduling priority"; "-n, --adjustment=N add integer N to the niceness (default 10)"; niceness ranges typically from -20 (most favorable) to 19.
最后验证: 2026-09-19 · 分类: 系统与设置