How to repeat
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_serviceThe -d flag highlights the differences between each refresh, making it easy to spot changes at a glance:
watch -d -n 10 docker restart my_serviceThis 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.