2019-04-21 11:50:48 +08:00

17 lines
1.5 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<h1 id="bg">bg</h1>
<p>用于将作业放到后台运行</p>
<h2 id="补充说明">补充说明</h2>
<p><strong>bg命令</strong> 用于将作业放到后台运行,使前台可以执行其他任务。该命令的运行效果与在指令后面添加符号<code>&amp;</code>的效果是相同的,都是将其放到系统后台执行。</p>
<p>在Linux系统中执行某些操作时候有时需要将当前任务暂停调至后台或有时须将后台暂停的任务重启开启并调至前台这一序列的操作将会使用到 jobs、bg、和 fg 三个命令以及两个快捷键来完成。</p>
<h3 id="语法">语法</h3>
<pre><code class="language-bash">bg(参数)</code></pre>
<h3 id="参数">参数</h3>
<p>作业标识:指定需要放到后台的作业标识号。</p>
<h3 id="实例">实例</h3>
<p>使用bg命令将任务号为1的任务放到后台继续执行输入如下命令</p>
<pre><code class="language-bash">bg 1 #后台执行任务号为1的任务</code></pre>
<p>如果系统中只有一个挂起的任务时即使不为该命令设置参数“1”也可以实现这个功能。</p>
<p>注意实际上使用bg命令与在指令后面添加符号“&amp;”的效果是一样的。例如,使用<code>&amp;</code><code>find / -name password</code>放到后台执行,输入如下命令:</p>
<pre><code class="language-bash">find / -name password &amp; #后台执行任务</code></pre>
<!-- Linux命令行搜索引擎https://jaywcjlove.github.io/linux-command/ -->