首页·终端命令

bg

进程与系统

用法

bg [%<job>]

把用 Ctrl+Z 停住的任务放回后台继续跑;它仍然属于当前 shell,关掉终端就一起结束,除非用了 nohup 或 disown。

常用选项

选项含义
%1Resume job number 1 in the background.
%% or %+The current job, which is what bg uses when given no argument.
%-The previous job.
%makeThe job whose command line starts with make.

示例

bg

Resume the job you just stopped with Ctrl+Z, in the background.

bg %2

Resume job 2 in the background while you keep using the shell.

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

怎么看

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

常见问题

Q. bg 是做什么的?

把用 Ctrl+Z 停住的任务放回后台继续跑;它仍然属于当前 shell,关掉终端就一起结束,除非用了 nohup 或 disown。

Q. 怎么写?

bg [%<job>] —— 方括号表示可以省略的部分。

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

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

相关命令

man 手册: man bg