# Running a script for only a single hour of the day

**URL:** <https://forum.inductiveautomation.com/t/running-a-script-for-only-a-single-hour-of-the-day/91429>\
**Category:** Ignition\
**Created:** [June 5, 2024, 5:37pm UTC](https://forum.inductiveautomation.com/t/running-a-script-for-only-a-single-hour-of-the-day/91429 "2024-06-05T17:37:23Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stephanie\_Aguiar](https://avatars.discourse-cdn.com/v4/letter/s/f17d59/32.png) [@Stephanie\_Aguiar](https://forum.inductiveautomation.com/u/Stephanie_Aguiar)\
**Post date:** [June 5, 2024, 5:37pm UTC](https://forum.inductiveautomation.com/t/running-a-script-for-only-a-single-hour-of-the-day/91429/1 "2024-06-05T17:37:23Z")

</div>

I would like to know if there is any way to run a script every day for only one hour. So lets say at 7am it starts and it runs it every minute until 8am and just keeps the last value as a static value.

---

<div class="post-metadata">

**Author:** ![michael.flagler](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/michael.flagler/32/26272_2.png) [@michael.flagler](https://forum.inductiveautomation.com/u/michael.flagler)\
**Post date:** [June 5, 2024, 5:43pm UTC](https://forum.inductiveautomation.com/t/running-a-script-for-only-a-single-hour-of-the-day/91429/2 "2024-06-05T17:43:56Z")

</div>

Off the top of my head, why not just use a timer script on the gateway that runs every minute, and checks the time to see if it's between the times you're wanting, and if it is, executes the script, and if not, it just does nothing.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [June 5, 2024, 5:51pm UTC](https://forum.inductiveautomation.com/t/running-a-script-for-only-a-single-hour-of-the-day/91429/3 "2024-06-05T17:51:38Z")

</div>

A gateway scheduled script can do it, probably a bit easier:  
[crontab.guru](https://crontab.guru/#*_7-8_*_*_*)

---

<div class="post-metadata">

**Author:** ![Stephanie\_Aguiar](https://avatars.discourse-cdn.com/v4/letter/s/f17d59/32.png) [@Stephanie\_Aguiar](https://forum.inductiveautomation.com/u/Stephanie_Aguiar)\
**Post date:** [June 5, 2024, 5:57pm UTC](https://forum.inductiveautomation.com/t/running-a-script-for-only-a-single-hour-of-the-day/91429/4 "2024-06-05T17:57:00Z")

</div>

How would I check the times? do you think you can provide an example script!

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [June 5, 2024, 6:00pm UTC](https://forum.inductiveautomation.com/t/running-a-script-for-only-a-single-hour-of-the-day/91429/5 "2024-06-05T18:00:57Z")

</div>

Alternative using gateway events:

 ![7am cron](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/6/b6ab3e70e82acb82a7f5fa8a07ebe2a9417baf8b.png)

---

<div class="post-metadata">

**Author:** ![michael.flagler](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/michael.flagler/32/26272_2.png) [@michael.flagler](https://forum.inductiveautomation.com/u/michael.flagler)\
**Post date:** [June 5, 2024, 7:49pm UTC](https://forum.inductiveautomation.com/t/running-a-script-for-only-a-single-hour-of-the-day/91429/6 "2024-06-05T19:49:17Z")

</div>

@Transistor has probably the best method, but the script to check if it's the hour you want would be something like this:

```python
if system.date.getHour24(system.date.now()) == 7:
    # Put your logic here

```
