Introduction
In Linux, the watch
command is extremely handy for running a command on a regular basis and displaying the results. This is particularly useful if you need to keep track of any changes in the output of a command that is run repeatedly. The watch command has no direct equivalent in Windows, however the while loop in Windows PowerShell or the for loops in a Windows command-line prompt (CMD) can achieve the same result.
Using WATCH
Create a file called watch.bat
inside C:\Windows\System32\
folder.
@ECHO OFF
:loop
cls
%*
timeout /t 5
goto loop
For example, prefixing the docker ps
command with watch works like this:
watch docker ps
Or you can use a top-like utility for monitoring CUDA on a GPU by the following command:
watch nvidia-smi