I have simple function;
You should create the timer on page load, and reload the page in the callback. When the page reloads, the timer will be re-created. This will "recursively" reload the page every 5 seconds.
As far as I know, there is no way to achieve this if you don't control the page you want to reload (i.e., using Dev Tools or console APIs). It's impossible to attach a script to execute on the next page load, and any active timers are cleared when the current page unloads. A browser extension is probably the way to go; for example, Content Scripts can be used to achieve this in Chrome.