I'm trying to find a simple way to repeatedly restart a command after a certain time (let's say 10 seconds for the purpose of this question). For simplicity let's say the command in question is htop --tree
.
My attempt so far: To just run and then stop a command once I found the commmand timeout
, so timeout 10 htop --tree
runs the command and stops it again after 10 seconds. To repeat that I found the command watch
which lets you rerun a command every given time interval. So my attempt was combining the two using
watch -n 10 `timeout 9 htop --tree`
but then it the output of htop
does not show up. Can anyone see what I'm doing wrong or how to fix that, or suggest an alternative bash solution for what I'm trying to achive?