Bump to procps-ng 3.3.17
[platform/upstream/procps-ng.git] / watch.1
1 .TH WATCH 1 "2020-12-06" "procps-ng" "User Commands"
2 .SH NAME
3 watch \- execute a program periodically, showing output fullscreen
4 .SH SYNOPSIS
5 .B watch
6 [\fIoptions\fR] \fIcommand\fR
7 .SH DESCRIPTION
8 .B watch
9 runs
10 .I command
11 repeatedly, displaying its output and errors (the first screenfull).  This
12 allows you to watch the program output change over time.  By default,
13 \fIcommand\fR is run every 2 seconds and \fBwatch\fR will run until interrupted.
14 .SH OPTIONS
15 .TP
16 \fB\-d\fR, \fB\-\-differences\fR[=\fIpermanent\fR]
17 Highlight the differences between successive updates. If the optional
18 \fIpermanent\fR argument is specified then
19 .B watch
20 will show all changes since the first iteration.
21 .TP
22 \fB\-n\fR, \fB\-\-interval\fR \fIseconds\fR
23 Specify update interval.  The command will not allow quicker than 0.1 second
24 interval, in which the smaller values are converted. Both '.' and ',' work
25 for any locales. The WATCH_INTERVAL environment can be used to persistently
26 set a non-default interval (following the same rules and formatting).
27 .TP
28 \fB\-p\fR, \fB\-\-precise\fR
29 Make
30 .BR watch
31 attempt to run
32 .I command
33 every
34 .B \-\-interval
35 .IR seconds .
36 Try it with
37 .B ntptime
38 (if present) and notice how the fractional seconds stays (nearly) the same, as opposed to
39 normal mode where they continuously increase.
40 .TP
41 \fB\-t\fR, \fB\-\-no\-title\fR
42 Turn off the header showing the interval, command, and current time at the
43 top of the display, as well as the following blank line.
44 .TP
45 \fB\-b\fR, \fB\-\-beep\fR
46 Beep if command has a non-zero exit.
47 .TP
48 \fB\-e\fR, \fB\-\-errexit\fR
49 Freeze updates on command error, and exit after a key press.
50 .TP
51 \fB\-g\fR, \fB\-\-chgexit\fR
52 Exit when the output of
53 .I command
54 changes.
55 .TP
56 \fB\-c\fR, \fB\-\-color\fR
57 Interpret ANSI color and style sequences.
58 .TP
59 \fB\-x\fR, \fB\-\-exec\fR
60 Pass
61 .I command
62 to
63 .BR exec (2)
64 instead of
65 .B sh \-c
66 which reduces the need to use extra quoting to get the desired effect.
67 .TP
68 \fB\-w\fR, \fB\-\-no\-linewrap\fR
69 Turn off line wrapping. Long lines will be truncated instead of wrapped to the next line.
70 .TP
71 \fB\-h\fR, \fB\-\-help\fR
72 Display help text and exit.
73 .TP
74 \fB\-v\fR, \fB\-\-version\fR
75 Display version information and exit.
76 .SH "EXIT STATUS"
77 .PP
78 .RS
79 .PD 0
80 .TP
81 .B 0
82 Success.
83 .TP
84 .B 1
85 Various failures.
86 .TP
87 .B 2
88 Forking the process to watch failed.
89 .TP
90 .B 3
91 Replacing child process stdout with write side pipe failed.
92 .TP
93 .B 4
94 Command execution failed.
95 .TP
96 .B 5
97 Closing child process write pipe failed.
98 .TP
99 .B 7
100 IPC pipe creation failed.
101 .TP
102 .B 8
103 Getting child process return value with
104 .BR waitpid (2)
105 failed, or command exited up on error.
106 .TP
107 .B other
108 The watch will propagate command exit status as child exit status.
109 .SH ENVIRONMENT
110 The behaviour of
111 .B watch
112 is affected by the following environment variables.
113
114 .TP
115 .B WATCH_INTERVAL
116 Update interval, follows the same rules as the
117 .B \-\-interval
118 command line option.
119 .SH NOTES
120 POSIX option processing is used (i.e., option processing stops at
121 the first non\-option argument).  This means that flags after
122 .I command
123 don't get interpreted by
124 .BR watch
125 itself.
126 .SH BUGS
127 Upon terminal resize, the screen will not be correctly repainted until the
128 next scheduled update.  All
129 .B \-\-differences
130 highlighting is lost on that update as well.
131
132 Non-printing characters are stripped from program output.  Use \fBcat -v\fR as
133 part of the command pipeline if you want to see them.
134
135 Combining Characters that are supposed to display on the character at the
136 last column on the screen may display one column early, or they may not
137 display at all.
138
139 Combining Characters never count as different in
140 .B \-\-differences
141 mode.  Only the base character counts.
142
143 Blank lines directly after a line which ends in the last column do not
144 display.
145
146 .B \-\-precise
147 mode doesn't yet have advanced temporal distortion technology to compensate
148 for a
149 .I command
150 that takes more than
151 .B \-\-interval
152 .I seconds
153 to execute.
154 .B watch
155 also can get into a state where it rapid-fires as many executions of
156 .I command
157 as it can to catch up from a previous executions running longer than
158 .B \-\-interval
159 (for example,
160 .B netstat
161 taking ages on a DNS lookup).
162 .SH EXAMPLES
163 .PP
164 To watch for mail, you might do
165 .IP
166 watch \-n 60 from
167 .PP
168 To watch the contents of a directory change, you could use
169 .IP
170 watch \-d ls \-l
171 .PP
172 If you're only interested in files owned by user joe, you might use
173 .IP
174 watch \-d 'ls \-l | fgrep joe'
175 .PP
176 To see the effects of quoting, try these out
177 .IP
178 watch echo $$
179 .br
180 watch echo '$$'
181 .br
182 watch echo "'"'$$'"'"
183 .PP
184 To see the effect of precision time keeping, try adding
185 .B \-p
186 to
187 .IP
188 watch \-n 10 sleep 1
189 .PP
190 You can watch for your administrator to install the latest kernel with
191 .IP
192 watch uname \-r
193 .PP
194 (Note that
195 .B \-p
196 isn't guaranteed to work across reboots, especially in the face of
197 .B ntpdate
198 (if present) or other bootup time-changing mechanisms)