How to Poll a URL with Watch and Curl in Linux
Polling a URL with `watch` and `curl` in Linux requires a single terminal command: `watch -n 5 curl -s https://example.com`. The `-n 5` flag tells `watch` to repeat the `curl` request every five seconds, while `-s` runs curl in silent mode. This combination lets you monitor URL responses in real time without writing any scripts.
If you want to quickly test a URL for changes, then the linux Watch command couple with Curl is a really simple way to hit a URL every n seconds (I use this for blue/green deployment testing to make sure there is no downtime when cutting over):
# Install watch command using homebrew
brew install watch
# Poll andrewbaker.ninja every 1 seconds
watch -n 1 curl andrewbaker.ninja