Skip to content
IT related

Watch

Updated 1 min read

On this page 1 section
  1. Watch Command

Watch Command

The Watch command is usefull for rerunning a command to watch the output. Intervals can be changed and the highlighting of changes in output cane be done.

Basic watch of a directory: watch ls -a

Watch a directory with specific interval in seconds: watch -n 60 ls -a

Watch with highlighting when things change: watch -n 60 --difference ls -a

Something more useful, here is how to watch the output of SMART self test with grep, usefull for running a full test and making sure the disk doesnt go to sleep:

watch -n 30 -d--cumulative 'smart -a /dev/sdb | grep -i -a5 "self-test log"'

The quotes around the 2 commands make sure that grep will grep the 'smart' output and not the 'watch' output. Grepping the watch output will just give you a blank screen.

-d--cumulative means that the changed bits will be highlighted one they change until you stop the command. If you do not have cumulative mode on then it will only highlight changes between the current run and previous run.

IT related RSS feed Published with Oblish

Keyboard shortcuts

/
Search
[
Previous page
]
Next page
?
Show this list
Esc
Close