WATCH(1) User Commands WATCH(1)

watch - Keep an eye on a command output.

watch [-n seconds] [-bt] command [args...]

The watch utility executes a command repeatedly every seconds seconds. This allows you to watch a program output change over the time.

It accepts the following options:

Specifies the interval to refresh the output. By default, the interval is of 2 seconds.
Beeps if the program being run returns a non-zero exit status.
Turns off the information header, letting just the verbatim program output being refreshed every time on the screen — equivalent to a ksh(1) for ((;;)) accompanied by sleep(1).
Not recommended, unless you're using tmux(1) or another terminal multiplexer that shows you information that would originally be shown by that header.

It can be very useful when backing up a disk and you need to see how many files were already copied.
Let's suppose you're copying a disk from a terminal and, in another, you want to keep an eye at du(1) output to see every minute if the file size matches with what you're expecting.

% watch -n 60 -b du -sh /dsk/1

This implementation supports intervals using both European or Anglo decimal separators, although sleeping in fractionated seconds does not make a lot of sense.

This implementation does not support the "WATCH_INTERVAL" environment variable.

execvp(3), nanosleep(2), curses(3X)

The watch(1) utility has a hazy history. Nobody seems to be actually sure of where it appeared first.
According to procps 010114's watch C source code, where it first appeared in that package, it was written from scratch by Tony Rems in 1991, and later recieved many modifications and corrections by François Pinard.
However, according to Internet Initiative Japan Inc.'s iwatch manual page, the watch utility came first from BSDi's BSD/OS 3.1 and their code is slightly derived from it; he/she who wrote the manual page and comments at the original source code also speculated that its existence was earlier than BSD/OS 3.1, from some another free distribution, but there's no further information that supports this.

This implementation mimics some of the basic behavior of procps-ng's watch, but only the necessary behavior to have a useful, simple and stable program.

06/14/23 Heirloom Toolchest