Skip to main content

watch

Explanation

The watch command runs a specified command repeatedly and displays its output and errors (the first screenfull). This allows you to watch the program output change over time. By default, the command is run every 2 seconds.

Basic Syntax

watch [OPTION]... COMMAND

Common Flags and Options

FlagDescription
-n, --interval=SECSSpecify update interval in seconds.
-d, --differences[=PERMANENT]Highlight the differences between successive updates.
-t, --no-titleTurn off the header showing the interval, command, and current time.

Real-world Examples

  1. Monitor disk space usage, updating every 2 seconds:

    watch df -h
  2. Watch the output of ls to see a file being downloaded:

    watch -n 1 ls -l largefile.iso
  3. Monitor memory usage and highlight changes:

    watch -d free -m