📄 bg.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><!-- Copyright 1997 The Open Group, All Rights Reserved --><title>bg</title></head><body bgcolor=white><center><font size=2>The Single UNIX ® Specification, Version 2<br>Copyright © 1997 The Open Group</font></center><hr size=2 noshade><h4><a name = "tag_000_000_172"> </a>NAME</h4><blockquote>bg - run jobs in the background</blockquote><h4><a name = "tag_000_000_173"> </a>SYNOPSIS</h4><blockquote><pre><code>bg <b>[</b><i>job_id</i> ...<b>]</b></code></pre></blockquote><h4><a name = "tag_000_000_174"> </a>DESCRIPTION</h4><blockquote>If job control is enabled (see the description of<i>set</i><b>-m</b>),the<i>bg</i>utility resumes suspended jobs from the current environment (see<xref href=shexenv><a href="chap2.html#tag_001_012">Shell Execution Environment</a></xref>)by running them as background jobs.If the job specified by<i>job_id</i>is already a running background job, the<i>bg</i>utility has no effectand will exit successfully.<p>Using<i>bg</i>to place a job into the background causes its process IDto become "known in the current shell execution environment",as if it had been started as an asynchronous list; see<xref href=asyncl><a href="chap2.html#tag_001_009_003">Lists</a></xref>.</blockquote><h4><a name = "tag_000_000_175"> </a>OPTIONS</h4><blockquote>None.</blockquote><h4><a name = "tag_000_000_176"> </a>OPERANDS</h4><blockquote>The following operand is supported:<dl compact><dt><i>job_id</i><dd>Specify the job to be resumed as a background job.If no<i>job_id</i>operand is given, the most recently suspended job is used.The format of<i>job_id</i>is described in the entry for<b>job control job ID</b>in the <b>XBD</b> specification, <a href="../xbd/glossary.html"><b>Glossary</b> </a> .</dl></blockquote><h4><a name = "tag_000_000_177"> </a>STDIN</h4><blockquote>Not used.</blockquote><h4><a name = "tag_000_000_178"> </a>INPUT FILES</h4><blockquote>None.</blockquote><h4><a name = "tag_000_000_179"> </a>ENVIRONMENT VARIABLES</h4><blockquote>The following environment variables affect the execution of<i>bg</i>:<dl compact><dt><i>LANG</i><dd>Provide a default value for the internationalisation variablesthat are unset or null.If<i>LANG</i>is unset or null, the corresponding value from theimplementation-dependent default locale will be used.If any of the internationalisation variables contains an invalid setting, theutility will behave as if none of the variables had been defined.<dt><i>LC_ALL</i><dd>If set to a non-empty string value,override the values of all the other internationalisation variables.<dt><i>LC_CTYPE</i><dd>Determine thelocale for the interpretation of sequences of bytes of text data ascharacters (for example, single- as opposed to multi-byte charactersin arguments).<dt><i>LC_MESSAGES</i><dd>Determine the locale that should be used to affectthe format and contents of diagnosticmessages written to standard error.<dt><i>NLSPATH</i><dd>Determine the location of message cataloguesfor the processing of<i>LC_MESSAGES .</i></dl></blockquote><h4><a name = "tag_000_000_180"> </a>ASYNCHRONOUS EVENTS</h4><blockquote>Default.<br></blockquote><h4><a name = "tag_000_000_181"> </a>STDOUT</h4><blockquote>The output of<i>bg</i>consists of a line in the format:<p><code><tt>"[%d] %s\n"</tt>, <<i>job-number</i>>,<<i>command</i>></code>where the fields are as follows:<dl compact><dt><b><</b><i>job-number</i><b>></b><dd>A number that can be used to identify the job to the<i><a href="wait.html">wait</a></i>,<i><a href="fg.html">fg</a></i>and<i><a href="kill.html">kill</a></i>utilities.Using these utilities, the job can be identifiedby prefixing the job number with"%".<dt><b><</b><i>command</i><b>></b><dd>The associated command that was given to the shell.</dl></blockquote><h4><a name = "tag_000_000_182"> </a>STDERR</h4><blockquote>Used only for diagnostic messages.</blockquote><h4><a name = "tag_000_000_183"> </a>OUTPUT FILES</h4><blockquote>None.</blockquote><h4><a name = "tag_000_000_184"> </a>EXTENDED DESCRIPTION</h4><blockquote>None.</blockquote><h4><a name = "tag_000_000_185"> </a>EXIT STATUS</h4><blockquote>The following exit values are returned:<dl compact><dt>0<dd>Successful completion.<dt>>0<dd>An error occurred.</dl></blockquote><h4><a name = "tag_000_000_186"> </a>CONSEQUENCES OF ERRORS</h4><blockquote>If job control is disabled, the<i>bg</i>utility will exit with an errorand no job will be placed in the background.</blockquote><h4><a name = "tag_000_000_187"> </a>APPLICATION USAGE</h4><blockquote>A job is generally suspended by typing the SUSP character(<control>-Zon most systems); seethe <b>XBD</b> specification, <a href="../xbd/termios.html"><b>General Terminal Interface</b> </a> .At that point,<i>bg</i>can put the job into the background.This is most effective when the jobis expecting no terminal input and itsoutput has been redirected to non-terminal files.A background job can be forced to stopwhen it has terminal output by issuing the command:<pre><code>stty tostop</code></pre><p>A background job can be stopped with the command:<pre><code>kill -s stop <i>job ID</i></code></pre><p>The<i>bg</i>utility will not work as expected when itis operating in its own utility execution environmentbecause that environment will have no suspended jobs.In the following examples:<pre><code>... | xargs bg(bg)</code></pre>each<i>bg</i>operates in a different environment and will not shareits parent shell's understanding of jobs.For this reason,<i>bg</i>is generally implemented as a shell regular built-in.</blockquote><h4><a name = "tag_000_000_188"> </a>EXAMPLES</h4><blockquote>None.</blockquote><h4><a name = "tag_000_000_189"> </a>FUTURE DIRECTIONS</h4><blockquote>None.</blockquote><h4><a name = "tag_000_000_190"> </a>SEE ALSO</h4><blockquote><i><a href="fg.html">fg</a></i>,<i><a href="kill.html">kill</a></i>,<i><a href="jobs.html">jobs</a></i>,<i><a href="wait.html">wait</a></i>.</blockquote><hr size=2 noshade><center><font size=2>UNIX ® is a registered Trademark of The Open Group.<br>Copyright © 1997 The Open Group<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]</font></center><hr size=2 noshade></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -