Create Global Event based on Time of Day

How do I go about creating an event to run a project script based on time of day?
I want to run a project script every day at 7am.

It depends on how precise you need it to be. I would recommend using a datetime memory tag holding your next deadline, and a fast-running timer event script that checks when the current time passes the deadline. At that point, compute and store back the next deadline and spawn the actual task as a background thread.

I have a similar scenario, I need a Gateway script to run at a certain time of the day.

An alternative way of doing this might be something like . . .

I have a Gateway Timer Script that runs once a minute or each 60,000 ms. The script simply gets the hour and minutes, checks the time, and runs the rest of the script if it’s a specific time.

import datetime

hour = int("%H"))
minute = int("%M"))
second = int("%S"))

if hour == 7 and minute == 0: # if its 7:00 AM, run the code below 
	Debug.LogMessage('Iscariot', system.tag.readBlocking(["[default]G01/G01/Station Data/ST1/ST 1 Total Bad Parts"])[0].value , str(hour) + " : " + str(minute) + " : " + str(second))

If you’re running current versions of Ignition 8 (not sure where exactly this was added, but it’s in 8.1.9), you have this option:

1 Like

That’s nice! I’m using 8.1.1. I Don’t have the Scheduler features

Scheduled scripts were added in 8.1.6. I’d suggest upgrading (for a variety of reasons) at your earliest convenience.

1 Like