I have a script that I would like to run at a predefined time (2am every morning). Looking through documentation, this sounds like I would want to use a Gateway Timer Event Script with a fixed rate. I can’t seem to find a good example for how to set this up. Would someone be able to help provide me an example of how to set this up? Where do I define the fixed rate? How do I define initial start? Does this need to be defined in the script somehow?
How soon/precise does it need to be after 2am? Pick a delay value that will check often enough. Use a datetime memory tag to hold the time of last full execution. The event script would then be something like this:
lastTS = system.tag.read("[default]path/to/timestamp/tag").value
currentTS = system.date.now()
today2am = system.date.setTime(currentTS, 2, 0, 0)
if currentTS.after(today2am) and lastTS.before(today2am):
# Do the rest of your 2am script here
Note that you don’t have to check initialChange with this algorithm, and it will automatically “catch up” if the server is disrupted/down when it would otherwise run.