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 segundosInterval between runs; 2 seconds by default.
-dHighlights the differences between one run and the next.
-tHides the header with the interval and time.
-eStops if the command returns an error.
-gExits when the command's output changes.
-cInterprets ANSI colors in the output.
-bBeeps if the command exits with an error.
Usage examples
watch -n 2 dateShows the time, updated every 2 seconds.
watch -d ls -lHighlights 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.