# Gateway Scheduled Task executing 4 times in a row

**URL:** <https://forum.inductiveautomation.com/t/gateway-scheduled-task-executing-4-times-in-a-row/72170>\
**Category:** Ignition\
**Tags:** ignition81, scripting\
**Created:** [April 6, 2023, 9:20pm UTC](https://forum.inductiveautomation.com/t/gateway-scheduled-task-executing-4-times-in-a-row/72170 "2023-04-06T21:20:26Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Neil\_Lewallen](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/neil_lewallen/32/87172_2.png) [@Neil\_Lewallen](https://forum.inductiveautomation.com/u/Neil_Lewallen)\
**Post date:** [April 6, 2023, 9:20pm UTC](https://forum.inductiveautomation.com/t/gateway-scheduled-task-executing-4-times-in-a-row/72170/1 "2023-04-06T21:20:26Z")

</div>

I have a Scheduled Gateway Script that I have tried both calling from my Parent Project Parent.GetPartnerCounts(), and directly within the script interface.(img1) The result either way is 4 returned loggers like the script is running multiple times when it executes. I have not found any reference to someone else seeing this error, and should also mention that the repeats all occur on the same timestamp (img2). Is there a command that I am missing to only run this scheduled task one time at the scheduled time? I want to be sure to clear this up before I start adding more Scheduled tasks that are executing SQL Stored Procedures for record keeping.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/4/743b64d05bcc670087c68bad9e32c6e74d342186.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/7/47ef9d9da2f068c3f3609c8618104a9ff9b9873d.png)

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [April 6, 2023, 9:22pm UTC](https://forum.inductiveautomation.com/t/gateway-scheduled-task-executing-4-times-in-a-row/72170/2 "2023-04-06T21:22:09Z")

</div>

Is this scheduled script defined in a parent project that is inherited by 4 other projects?

---

<div class="post-metadata">

**Author:** ![Neil\_Lewallen](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/neil_lewallen/32/87172_2.png) [@Neil\_Lewallen](https://forum.inductiveautomation.com/u/Neil_Lewallen)\
**Post date:** [April 6, 2023, 9:28pm UTC](https://forum.inductiveautomation.com/t/gateway-scheduled-task-executing-4-times-in-a-row/72170/3 "2023-04-06T21:28:25Z")

</div>

Yes. So it is executing on all the projects? Can I avoid that by specifying the parent project in the call?

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [April 6, 2023, 9:29pm UTC](https://forum.inductiveautomation.com/t/gateway-scheduled-task-executing-4-times-in-a-row/72170/4 "2023-04-06T21:29:46Z")

</div>

I'm not sure what "call" you're talking about. This is a scheduled script. It's going to execute on the defined schedule, there is no call to it. Since you inherit this scheduled script 4 times, it runs 4 times.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [April 6, 2023, 9:30pm UTC](https://forum.inductiveautomation.com/t/gateway-scheduled-task-executing-4-times-in-a-row/72170/5 "2023-04-06T21:30:39Z")

</div>

It almost sounds like you want to just be writing shared code in the script module section that your child projects can call when necessary. Not scheduled scripts.

see [Project Library - Ignition User Manual 8.1 - Ignition Documentation](https://docs.inductiveautomation.com/display/DOC81/Project+Library)

---

<div class="post-metadata">

**Author:** ![Neil\_Lewallen](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/neil_lewallen/32/87172_2.png) [@Neil\_Lewallen](https://forum.inductiveautomation.com/u/Neil_Lewallen)\
**Post date:** [April 6, 2023, 9:43pm UTC](https://forum.inductiveautomation.com/t/gateway-scheduled-task-executing-4-times-in-a-row/72170/6 "2023-04-06T21:43:39Z")

</div>

So, I moved the Scheduled script definition from the Parent Project down to a single child project, then defined the Scheduled Script on the child. I then saw the results I expected. Thank you for clearing up my confusion. I will adjust the logic and call it correctly based on the projects. I appreciate the quick response.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/3/d3297ad9fe3e91767a581b1602d6b0452bd8d778.png)
