Imagine you are going to perform a stress test. You want to restart a service repeatedly to make sure the whole system is fault-tolerant. watch is your magic command here. You can use the watch command to repeat a task.

For example you can restart a Docker service every 10 seconds:

watch -n 10 docker restart my_service

The -d flag highlights the differences between each refresh, making it easy to spot changes at a glance:

watch -d -n 10 docker restart my_service

This is simple but makes your life easier. Give it a try!

You can also pair watch with tmux to monitor multiple services side by side.