使用 watch 命令

watch 命令允许您在全屏中持续运行任何 Linux 命令。它还允许更改命令运行之间的时间间隔,以及突出显示每次运行之间的差异。

参数

使用 -n 选项设置每次命令运行之间的时间间隔,以秒为单位。(-n0 将间隔设置为 0.1 秒,这是最快的可用刷新率;默认间隔为 2 秒,最长间隔为 4294 秒)。

使用 --differences 选项突出显示命令运行之间的更改。

示例

cl-rctl ip route

此命令显示 Cumulus Linux 路由表。

watch -n0 --differences sudo cl-rctl ip route
watch command for cl-rctl ip route

此命令显示接口数据包计数器。

watch -n0 --differences sudo ip -s link show up
watch command for ip dash s link show