Scheduled Task is the way to go.
Although a minor issue here is that Scheduled Tasks require a minimum interval of 1 minute
But if you want to still do it for every 5 seconds, there is a hack that may work.
Just schedule that task for every minute. In that task, create an infinite loop with sleep for 5 seconds. That task will be running continuously for a long time (Usually a week or two). After that time, when it vanishes, it will be restarted within a minute.