Skip to main content

watch

The watch command repeated runs a command or job for you. It is used like this:

watch [options] [command]

The [options] are listed below and the [command] is the command you want to run repeatedly.

watch options

option flagUse
-n, --intervalspecifies the interval between runs of the passed command. The default is 2 seconds.
-d, --differencesHighlight any differences between updates.
-g, --chgexitExits if the output of the passed command changes
-t, --no-titleRemoves the header with the interval, command, and current time
-b, --beepPlay a sound if the command exits with an error
-p, --preciseAttempt to run exactly on the specified --interval
-e, --errexitStops updates on an error from the passed command and exits on the next key press
-c, --colorPass an ANSI color and style sequence
-x, --execPasses user defined command to exec. Reduces the need for additional quoting
-w, --no-linewrapTruncated any long lines
-h, --helpDisplay help text (this info)
-v, --versionDisplay version info

Helpful use cases

Continually get Pods when watching an update

watch kubectl get pods