1WATCH(1) User Commands WATCH(1)
2
3
4
6 watch - execute a program periodically, showing output fullscreen
7
9 watch [options] command
10
12 watch runs command repeatedly, displaying its output and errors (the
13 first screenfull). This allows you to watch the program output change
14 over time. By default, command is run every 2 seconds and watch will
15 run until interrupted.
16
18 -d, --differences [permanent]
19 Highlight the differences between successive updates. Option
20 will read optional argument that changes highlight to be perma‐
21 nent, allowing to see what has changed at least once since first
22 iteration.
23
24 -n, --interval seconds
25 Specify update interval. The command will not allow quicker
26 than 0.1 second interval, in which the smaller values are con‐
27 verted. Both '.' and ',' work for any locales.
28
29 -p, --precise
30 Make watch attempt to run command every interval seconds. Try it
31 with ntptime and notice how the fractional seconds stays
32 (nearly) the same, as opposed to normal mode where they continu‐
33 ously increase.
34
35 -t, --no-title
36 Turn off the header showing the interval, command, and current
37 time at the top of the display, as well as the following blank
38 line.
39
40 -b, --beep
41 Beep if command has a non-zero exit.
42
43 -e, --errexit
44 Freeze updates on command error, and exit after a key press.
45
46 -g, --chgexit
47 Exit when the output of command changes.
48
49 -c, --color
50 Interpret ANSI color and style sequences.
51
52 -x, --exec
53 Pass command to exec(2) instead of sh -c which reduces the need
54 to use extra quoting to get the desired effect.
55
56 -h, --help
57 Display help text and exit.
58
59 -v, --version
60 Display version information and exit.
61
63 0 Success.
64 1 Various failures.
65 2 Forking the process to watch failed.
66 3 Replacing child process stdout with write side pipe
67 failed.
68 4 Command execution failed.
69 5 Closing child process write pipe failed.
70 7 IPC pipe creation failed.
71 8 Getting child process return value with waitpid(2)
72 failed, or command exited up on error.
73 other The watch will propagate command exit status as child
74 exit status.
76 POSIX option processing is used (i.e., option processing stops at the
77 first non-option argument). This means that flags after command don't
78 get interpreted by watch itself.
80 Upon terminal resize, the screen will not be correctly repainted until
81 the next scheduled update. All --differences highlighting is lost on
82 that update as well.
83
84 Non-printing characters are stripped from program output. Use "cat -v"
85 as part of the command pipeline if you want to see them.
86
87 Combining Characters that are supposed to display on the character at
88 the last column on the screen may display one column early, or they may
89 not display at all.
90
91 Combining Characters never count as different in --differences mode.
92 Only the base character counts.
93
94 Blank lines directly after a line which ends in the last column do not
95 display.
96
97 --precise mode doesn't yet have advanced temporal distortion technology
98 to compensate for a command that takes more than interval seconds to
99 execute. watch also can get into a state where it rapid-fires as many
100 executions of command as it can to catch up from a previous executions
101 running longer than interval (for example, netstat taking ages on a DNS
102 lookup).
104 To watch for mail, you might do
105 watch -n 60 from
106 To watch the contents of a directory change, you could use
107 watch -d ls -l
108 If you're only interested in files owned by user joe, you might use
109 watch -d 'ls -l | fgrep joe'
110 To see the effects of quoting, try these out
111 watch echo $$
112 watch echo '$$'
113 watch echo "'"'$$'"'"
114 To see the effect of precision time keeping, try adding -p to
115 watch -n 10 sleep 1
116 You can watch for your administrator to install the latest kernel with
117 watch uname -r
118 (Note that -p isn't guaranteed to work across reboots, especially in
119 the face of ntpdate or other bootup time-changing mechanisms)
120
121
122
123procps-ng 2018-03-03 WATCH(1)