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

17 lines
1.2 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="nice">nice</h1>
<p>改变程序执行的优先权等级</p>
<h2 id="补充说明">补充说明</h2>
<p><strong>nice命令</strong> 用于以指定的进程调度优先级启动其他的程序。</p>
<h3 id="语法">语法</h3>
<pre><code class="language-bash">nice(选项)(参数)</code></pre>
<h3 id="选项">选项</h3>
<pre><code class="language-bash">-n指定进程的优先级整数</code></pre>
<h3 id="参数">参数</h3>
<p>指令及选项:需要运行的指令及其他选项。</p>
<h3 id="实例">实例</h3>
<p>新建一个进程并设置优先级将当前目录下的documents目录打包但不希望tar占用太多CPU</p>
<pre><code class="language-bash">nice -19 tar zcf pack.tar.gz documents</code></pre>
<p>方法非常简单,即在原命令前加上<code>nice -19</code>。很多人可能有疑问了最低优先级不是19么那是因为这个“-19”中的“-”仅表示参数前缀所以如果希望将当前目录下的documents目录打包并且赋予tar进程最高的优先级</p>
<pre><code class="language-bash">nice --19 tar zcf pack.tar.gz documents</code></pre>
<!-- Linux命令行搜索引擎https://jaywcjlove.github.io/linux-command/ -->