LinuxCommandLibrary

ca.1s

Access system calls via shared library

SYNOPSIS

watch [options] command

PARAMETERS

-b, --beep
    Beep if command has changed.

-c, --color
    Interpret ANSI color and style sequences.

-d, --differences[=cumulative]
    Highlight the differences between successive updates. With cumulative, highlight all changes since the first update.

-e, --errexit
    Exit if the command has a non-zero exit status.

-g, --chgexit
    Exit when the output of the command changes.

-n, --interval
    Specify the interval between updates in seconds. A non-integer argument is rejected.

-p, --precise
    Attempt to run command every with high precision.

-t, --no-title
    Turn off showing the header showing the interval, command, and current time at the top of the display.

-v, --version
    Output version information and exit.

-x, --exec
    Pass command to sh -c which expands shell variables.

DESCRIPTION

The `watch` command in Linux executes a specified command repeatedly at a set interval and displays its output. This is particularly useful for monitoring the status of running processes, system resources, or any other dynamically changing information. By default, the command is executed every 2 seconds. The output is displayed in a full-screen format, with the differences between successive executions highlighted. The `watch` command provides a continuous, real-time view of the command's results, allowing users to observe changes without manually re-running the command. It helps track log files, check network connectivity, monitor CPU and memory usage, and is invaluable for system administrators and developers for debugging and system monitoring.

USAGE EXAMPLES

1. Monitor CPU usage:
`watch -n 1 'mpstat 1 1 | awk '$NF ~ /idle/ {print 100-$NF}'`

2. Monitor free disk space:
`watch df -h`

HISTORY

The `watch` command has been a part of Unix-like operating systems for a long time, designed as a simple yet effective tool for monitoring dynamic system information. It is used to execute another program periodically, showing the changes that occur over time. It has become an essential command for system administrators for the real-time monitoring of system metrics and running processes.

SEE ALSO

top(1), ps(1), tail(1), uptime(1)

Copied to clipboard