ubuntu 中watch命令的使用

前言

因为需要监控一下GPU的使用情况,搜索了一下怎么能够每隔一秒刷新一下使用情况,发现watch命令可以完美实现这个需要,这里对这个命令总结一下。

功能

watch可以帮你监测一个命令的运行结果,省得你一遍遍的手动运行。在Linux下,watch是周期性的执行下个程序,并显示执行结果。你可以拿他来监测你想要的一切命令的结果变化。
常见命令参数:
Usage: watch [-dhntv] [–differences[=cumulative]] [–help] [–interval=] [–no-title] [–version]
-d, --differences[=cumulative] highlight changes between updates
(cumulative means highlighting is cumulative)
-h, --help print a summary of the options
-n, --interval= seconds to wait between updates
-v, --version print the version number
-t, --no-title turns off showing the header

比如我要监控GPU的使用情况,就使用watch -n 1 nvidia-smi这组命令,其中“-n”代表每隔多少秒刷新一次,结果如下:
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_29566629/article/details/89373129