# How to execute a script via time or/and via update?

**URL:** <https://forum.inductiveautomation.com/t/how-to-execute-a-script-via-time-or-and-via-update/115687>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [May 25, 2026, 9:23am UTC](https://forum.inductiveautomation.com/t/how-to-execute-a-script-via-time-or-and-via-update/115687 "2026-05-25T09:23:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![danielps1818](https://avatars.discourse-cdn.com/v4/letter/d/ecae2f/32.png) [@danielps1818](https://forum.inductiveautomation.com/u/danielps1818)\
**Post date:** [May 25, 2026, 9:23am UTC](https://forum.inductiveautomation.com/t/how-to-execute-a-script-via-time-or-and-via-update/115687/1 "2026-05-25T09:23:39Z")

</div>

Hi!

I have a tag that changes. I don't know when it's going to change. It's dependedant on a machine.

I have an script that executes whenever the tag changes. However, because the tag could be more than 30 seconds without executing. I would like to execute the script again.

The conditions:

- The script should execute everytime the tag changes
- The script should execute if more than 30 seconds before the last script execution have passed

I'm not really sure how to aproach this...

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [May 25, 2026, 2:55pm UTC](https://forum.inductiveautomation.com/t/how-to-execute-a-script-via-time-or-and-via-update/115687/2 "2026-05-25T14:55:32Z")

</div>

Move the existing script to a function in a project library script. (You should do this anyways, always.) Add to the beginning of the script a write of `system.date.now()` to a datetime memory tag. Change the tag event to call the project library script.

In the same project library, create a new function that reads the source tag and reads the memory tag. If the memory tag is more than 30s in the past, call the above function.

Make a 1-second timer event call the 2nd function.
