Use reporting to run scheduled gateway scripts

Unfortunately, the gateway scripts don’t have a ton of flexibility - just a timer and an option between fixed and rate delays. Seems like saving also resets these timers. That isn’t super conducive to running scripts at certain hours (like trying to run when the load is less for longer scripts), or just wanting some more control over how often scripts are run.

I’m wondering if anyone has insight into creating a dummy report, setting a schedule to run whenever you need it to, and put the script (or call something in a global script) in the ‘actions’ tab for that schedule.

I’ve technically done this and ran a very small script that just logged to the gateway so I can make sure it works, and it does. I’m just wondering if there are any other considerations I should make (for longer scripts or something) or if its more or less like running a gateway timer script.

1 Like

We do this for report processing and emailing to get them all into one email.
I haven’t see any issues with it.
I don’t think you will get an “official” response on this as you are using something not for its intended purpose.

1 Like

Guess I’ll write an “unofficial response”. :wink:

I don’t see any technical reasons why it wouldn’t work. As a bonus, you can save your generated dummy report as proof that the script at least tried to run.

We do plan on adding the ability to use the same cron engine reporting uses to schedule scripts, but I have absolutely no timeframe on when that will happen.

2 Likes

Great! I didn’t think there would be but with an unintended use I thought I’d at least see if anyone’s alarm bells went off. And more cron stuff would be really great! Looking forward to seeing more in time.

The only minor issue I would see is that it’s theoretically more likely for the reporting module to be faulted/in a failure state than the entire platform.

1 Like

Another method would be to use a value change script on an expression tag. The script should start with if newValue == 1: and the expression should evaluate to true at the time you want the script to run. For example, if you want the script to run at 2:00 AM, the expression would be dateExtract(now(),‘hr’) = 2.

Is there a limit to what can be written in a Report Script? I have been trying to call a Shared function from the Script Library, and even a simple write to a client tag, just to test the functionality. I have yet to see anything that has fired. Using the Report Script in this way sounds like it would be perfect if I could get it to work :laughing:

Thanks!! Happy New Year! :partying_face:

1 Like

:man_facepalming:

Five hours later, and I have come to the conclusion that you cannot write to a Client Tag from a Report that is run from the Gateway.

IU 101

2 Likes

Nothing that runs in the gateway can write to client tags. They don’t exist in the gateway at all. However, you could send a message to client scope, and the message handler will run in client scope. That message handler could take an item from the payload (set in the gateway) and write it to a client tag. Just make sure that the payload items are all serializable for transmission.

2 Likes

:pray:

1 Like