Where to start First steps track · 15 stages
Linux Labs

watch — periodically repeat a command

cheat sheet · procps https://lab.dimsanych.ru/en/wiki/watch/

Cheat sheet

  • watch -n1 -d 'command' every second, highlight changes
  • watch cat /proc/mdstat progress (RAID/jobs)
  • watch 'ss -tlnp | grep :80' quotes for the pipeline!
  • watch -g cmd exit when the output changes
  • watch -c 'docker ps' with color

Options

Always quote a command that has a pipeline or a wildcard (|, *) — otherwise the shell parses them before watch even runs, instead of the repeated command doing so. By default watch strips ANSI color from the output; -c turns it back on for commands that color their own text.

Loading…