watch

Linux · Processes · reference only

What it does

Runs a command repeatedly every few seconds and shows its output full screen, so you can watch it change.

Syntax

watch [opciones] comando

Options and parameters

  • -n segundos

    Interval between runs; 2 seconds by default.

  • -d

    Highlights the differences between one run and the next.

  • -t

    Hides the header with the interval and time.

  • -e

    Stops if the command returns an error.

  • -g

    Exits when the command's output changes.

  • -c

    Interprets ANSI colors in the output.

  • -b

    Beeps if the command exits with an error.

Usage examples

  • watch -n 2 date

    Shows the time, updated every 2 seconds.

  • watch -d ls -l

    Highlights changes in a directory while you work.

  • watch -n 1 'df -h /'

    Watches the root disk usage change every second.

  • watch -g 'ls | wc -l'

    Waits until the number of files in the directory changes.

Notes and common mistakes

  • Press Ctrl+C to exit.
  • If the command has pipes or several words, put it in quotes.

Related commands