From 790b7f7341aebf11f75574957070ed94090ce309 Mon Sep 17 00:00:00 2001
From: Xingyu Wang <xingyu.wang@gmail.com>
Date: Wed, 22 Sep 2021 10:46:47 +0800
Subject: [PATCH] PRF&PUB

@geekpi
https://linux.cn/article-13810-1.html
---
 ... and tasks with the Linux watch command.md | 37 ++++++++-----------
 1 file changed, 15 insertions(+), 22 deletions(-)
 rename {translated/tech => published}/20210916 Watch commands and tasks with the Linux watch command.md (82%)

diff --git a/translated/tech/20210916 Watch commands and tasks with the Linux watch command.md b/published/20210916 Watch commands and tasks with the Linux watch command.md
similarity index 82%
rename from translated/tech/20210916 Watch commands and tasks with the Linux watch command.md
rename to published/20210916 Watch commands and tasks with the Linux watch command.md
index 60226c9c42..4bd279ab40 100644
--- a/translated/tech/20210916 Watch commands and tasks with the Linux watch command.md	
+++ b/published/20210916 Watch commands and tasks with the Linux watch command.md	
@@ -3,14 +3,16 @@
 [#]: author: "Moshe Zadka https://opensource.com/users/moshez"
 [#]: collector: "lujun9972"
 [#]: translator: "geekpi"
-[#]: reviewer: " "
-[#]: publisher: " "
-[#]: url: " "
+[#]: reviewer: "wxy"
+[#]: publisher: "wxy"
+[#]: url: "https://linux.cn/article-13810-1.html"
 
 用 Linux 的 watch 命令观察命令和任务
 ======
-了解 watch 命令如何让你知道任务已完成或命令已执行。
-![Clock, pen, and notepad on a desk][1]
+
+> 了解 watch 命令如何让你知道任务已完成或命令已执行。
+
+![](https://img.linux.net.cn/data/attachment/album/202109/22/104541ddfgzpvud5ga55sp.jpg)
 
 有很多时候,你需要等待一些事情的完成,比如:
 
@@ -18,19 +20,14 @@
   * 创建或解压一个 [tar][2] 文件。
   * 一个 [Ansible][3] 作业。
 
-
-
 其中一些进程有进度指示,但有时进程是通过一层抽象运行的,衡量进度的唯一方法是通过其副作用。其中一些可能是:
 
   * 一个正在下载的文件不断增长。
   * 一个从 tarball 中提取的目录被文件填满了。
   * Ansible 作业构建了一个[容器][4]。
 
-
-
 你可以用这样的命令查询所有这些:
 
-
 ```
 $ ls -l downloaded-file
 $ find . | wc -l
@@ -38,11 +35,10 @@ $ podman ps
 $ docker ps
 ```
 
-但是反复运行这些命令,即使是利用 [Bash 历史][5]和**向上箭头**的便利,也是很乏味的。
+但是反复运行这些命令,即使是利用 [Bash 历史][5] 和**向上箭头**的便利,也是很乏味的。
 
 另一种方法是写一个小的 Bash 脚本来为你自动执行这些命令:
 
-
 ```
 while :
 do
@@ -57,7 +53,7 @@ done
 
 ### 安装 watch
 
-`watch` 命令是 [`procps-ng` 包][6]的一部分,所以如果你是在 Linux 上,你已经安装了它。
+`watch` 命令是 [procps-ng 包][6]的一部分,所以如果你是在 Linux 上,你已经安装了它。
 
 在 macOS 上,使用 [MacPorts][7] 或 [Homebrew][8] 安装 `watch`。在 Windows 上,使用 [Chocolatey][9]。
 
@@ -69,16 +65,14 @@ done
 
 例如,在 `docker ps` 命令前加上 `watch`,就可以这样操作:
 
-
 ```
-`$ watch docker ps`
+$ watch docker ps
 ```
 
 用 `watch` 命令,以及一些创造性的 Unix 命令行技巧,可以生成临时的仪表盘。例如,要计算审计事件:
 
-
 ```
-`$ watch 'grep audit: /var/log/kern.log |wc -l'`
+$ watch 'grep audit: /var/log/kern.log |wc -l'
 ```
 
 在最后一个例子中,如果有一个可视化的指示,表明审计事件的数量发生了变化,这可能是有用的。如果变化是预期的,但你想让一些东西看起来“不同”,`watch --differences` 就很好用。它可以高亮显示与上次运行的任何差异。如果你在多个文件中搜索,这一点尤其有效,所以你可以很容易地看到哪个文件发生了变化。
@@ -87,16 +81,15 @@ done
 
 ### 控制频率
 
-最后,有时该命令可能是资源密集型的,不应运行得太频繁。`-n` 参数控制频率。Watch 默认使用 2 秒,但是 `watch -n 10` 可能适合于资源密集型的情况,比如在子目录的任何文件中搜索一个模式:
-
+最后,有时该命令可能是资源密集型的,不应运行得太频繁。`-n` 参数控制频率。`watch` 默认使用 2 秒间隔,但是 `watch -n 10` 可能适合于资源密集型的情况,比如在子目录的任何文件中搜索一个模式:
 
 ```
-`$ watch -n 10 'find . -type f | xargs grep suspicious-pattern'`
+$ watch -n 10 'find . -type f | xargs grep suspicious-pattern'
 ```
 
 ### 用 watch 观察一个命令
 
-`watch` 命令对于许多临时性的系统管理任务非常有用,在这些任务中,你需要在没有进度条的情况下等待一些耗时的步骤,然后再进入下一个步骤。尽管这种情况并不理想,但 `watch` 可以使情况稍微好转。它让你有时间为工作做回顾性笔记!"。下载**[备忘录][10]**,让有用的语法和选项触手可及。。
+`watch` 命令对于许多临时性的系统管理任务非常有用,在这些任务中,你需要在没有进度条的情况下等待一些耗时的步骤,然后再进入下一个步骤。尽管这种情况并不理想,但 `watch` 可以使情况稍微好转。它让你有时间为工作做回顾性笔记!"。下载 [备忘录][10],让有用的语法和选项触手可及。。
 
 --------------------------------------------------------------------------------
 
@@ -105,7 +98,7 @@ via: https://opensource.com/article/21/9/linux-watch-command
 作者:[Moshe Zadka][a]
 选题:[lujun9972][b]
 译者:[geekpi](https://github.com/geekpi)
-校对:[校对者ID](https://github.com/校对者ID)
+校对:[wxy](https://github.com/wxy)
 
 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出