How to create a ticker or timer to refresh() every so often

I am new to groovy, but not to development in general.

I am trying to create a ticker using runIn(seconds, 'methodName'), like this:

def ticker() {
refresh()
runIn(4, "ticker")
}

In order to have a refresh every 4 seconds, sometimes it seems to work, sometimes it takes longer between ticks, and then it just stops, and then comes back a couple minutes later.

Do you have any best practices you can recommend on how to do this in HUBITAT & groovy in a reliable implementation.

Thanks!!!