Windows: `Watch` Equivalent – CMD & PowerShell

The watch command in Linux is used to execute a command periodically and show the output.

This is extremely useful if you need to track any changes in the output of a repeatedly executed command.

There is no direct equivalent for the watch command in Windows, however the same result can be achieved using the while loop in a Windows PowerShell or the for loops in a Windows command-line prompt (CMD).

Cool Tip: Windows grep command equivalent in CMD and PowerShell! Read more →

`Watch` Command in Windows

Use the oneliners below to execute some command periodically (each 5 seconds) and print the output of each execution.

The watch command equivalent in Windows command-line prompt (CMD):

C:\> for /l %g in () do @(<command> & timeout /t 5)

The watch command equivalent in Windows PoweShell:

PS C:\> while (1) {<command>; sleep 5}

One Reply to “Windows: `Watch` Equivalent – CMD & PowerShell”

  1. Thanks for this.

    To emulate watch displaying on a clear screen instead of scrolling I prepended the DOS “cls”

    C:\> for /l %g in () do @(cls & & timeout /t 5)

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.