Justin Lin ⟔

Run command in a loop with delay

[#note]

watch is a lightweight way to run something in a loop with a delay. This will run the command every 5 seconds:

watch -n 5 $command

For example, this will run until output of a curl request changes and then trigger a telegram notification. You can use tmux/screen to keep the command alive.

watch -n 60 -g -d -x curl -s 'https://google.com'; telegram-send "change detected"

Back