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 "user-defined" 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. Per 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 backuping some disc and needing to see how many files were already copied.
Lets suppose you're copying a disc 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 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 has 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 Francois Pinard.
However, according to Internet Initiative Japan Inc.'s iwatch manual page, the watch utility came first from BSDI Inc. 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 mimicks some of the basic behavior of procps-ng's watch, just the necessary to have a useful, simple and stable program.

06/14/23 Heirloom Toolchest