← ~/blog

A Tiny Ode to watch and \watch

 /  systems  /  181 words

Short one because I have been heads down for a month and my drafts folder is a graveyard, but this saved me twice this week so it earns a post.

Two tools, same idea. In the shell, watch reruns any command every two seconds and shows the output full screen. watch -d highlights what changed between runs, which turns "is the queue draining" from a question you keep asking into a screen you glance at. I use watch -d 'kafka-consumer-groups ... | grep LAG' during every incident now and it is embarrassing how long I lived without it.

Inside Postgres, \watch does the same thing for whatever query you just ran. Write your diagnostic query once, type \watch 5, and psql reruns it every five seconds. Live view of lock contention, replication lag, table bloat, anything, with zero tooling installed.

Neither of these is news to anyone who reads man pages for fun. But I watched a coworker mash the up arrow and enter for ten straight minutes last week, so apparently the word still needs spreading. Stop mashing. Start watching.