Skip to content

Using the watch command on Linux

Watch is a command on Linux that will repeatedly run commands for you, and it offers some very useful options. One of its basic options is that you can tell watch how long to wait before running the specified command again. For example, if you run the command watch -n 10 date, the watch command will first clear the screen and run the date command right away. After that, it will run the command every 10 seconds until you stop it by hitting control-C. Note that the first line on the screen will indicate the wait time between iterations (every 10 seconds).

$ watch -n 10 date
Every 10.0s: date fedora: Fri, Aug 12 16:32:09 EDT 2022

Fri Aug 12 04:10:11 PM EDT 2022

The -n option specifies the number of seconds between commands. The default is 2. You might have to look closely to notice the changes in the output.

To read this article in full, please click here

Source:: Network World – Linux