Design Pattern: Looping Timers

What is the best way to implement a daemon process which runs always? I don’t want to start it in the “system startup” event because if I develop it I don’t want to restart the system in every minute. So I have created this cron below to start it. But if I change the code, I got I huge exception in the logs. I don’t have problem with that, but is this the best solution for it?

var Timer timer = null

rule "cron process"
when
	Time cron "0/10 * * * * ? *"
then
	if (timer === null)
	{
		logInfo("cron", "start timer")
		timer = createTimer(now, [ |
        	//do the job here....
			
			timer.reschedule(now.plusMillis(200))
    	])
	}
end
2 Likes