watch

Command Function

This command is used to periodically monitor the execution result of a command.

Syntax

watch

watch [-c/-n/-t/--count/--interval/-no-title/--over] [command]

Parameters

Table 1 Parameter description

Parameter

Description

Default Value

Value Range

-c / --count

Specifies the number of times that the command is executed.

0xFFFFFF

(0, 0xFFFFFF]

-n / --interval

Specifies the interval for periodically running the command, in seconds.

1s

(0, 0xFFFFFF]

-t / -no-title

Disables time display on the top.

N/A

N/A

command

Specifies the command to be monitored.

N/A

N/A

--over

Stops the current command monitoring.

N/A

N/A

Usage

You can run the watch --over command to stop the currently running command monitoring.

Example

Example:

watch -n 2 -c 6 task

Output Description

Figure 1 task command monitoring result

NOTE: In this example, the task command has been executed every 2 seconds for six times, and the preceding figure shows the output of the last execution.