When does a gateway timer script start?

I have a script I need to run at the top of the hour but say the gateway restarts at the 59th minute. Would It not be executed again until another hour has passed?

If you want a timer script to run at the top of the hour you need to run it fast, look at the current time, and then bookkeep that it ran so you don't do it again until the next hour.

Or just use Scheduled Scripts, which are intended for this kind of thing.

2 Likes

If the gateway misses the scheduled time because it was unavailable, do you want it to wait until the next scheduled time or do you want it to "catch up" on the missed execution?

I think (based on the documentation) if you use a scheduled script it will do the first one, but if you use a fast timer script you have a lot more control, including the second one.

So just for clarity, the timer script is reset when the gateway restarts? I assume the event is dispatched on some timer thread when the gateway starts up?

As @Felipe_CRM mentioned, I need it to "catch up" so as you mentioned I would need to run it fast and keep a log.

I recommend using a project library script, that when called, examines your history or log or some "state" of what you've done, and then does what is due, and logs it. If nothing is due, do nothing.

Call this script function from a gateway startup script (which will also run on project saves), and from a scheduled event.

Way less extra checking.

2 Likes

Timer scripts are not scheduled by time, but rather by delay. When the project they are defined in starts, or a new timer task is added, it's scheduled to run at the delay/period. Wall clock is irrelevant.

1 Like