# Cause of logs (Restarting gateway scripts)

**URL:** <https://forum.inductiveautomation.com/t/cause-of-logs-restarting-gateway-scripts/69584>\
**Category:** Ignition\
**Tags:** ignition79\
**Created:** [February 8, 2023, 4:07pm UTC](https://forum.inductiveautomation.com/t/cause-of-logs-restarting-gateway-scripts/69584 "2023-02-08T16:07:02Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![FABRICIO\_VILATUNA](https://avatars.discourse-cdn.com/v4/letter/f/4af34b/32.png) [@FABRICIO\_VILATUNA](https://forum.inductiveautomation.com/u/FABRICIO_VILATUNA)\
**Post date:** [February 8, 2023, 4:07pm UTC](https://forum.inductiveautomation.com/t/cause-of-logs-restarting-gateway-scripts/69584/1 "2023-02-08T16:07:02Z")

</div>

I use a Gateway Script through Tag Change, a log is created in a DB, but reviewing the saved data I noticed that 2 logs were created that should not be, looking at the Logs I noticed that at 11:51:01 and 11:51:47 the Log is executed: Restarting gateway scripts....

How can I prevent the Log: Restarting gateway scripts from executing?

 ![imagen](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/9/b96b671b69b22586d7c8a914a97506447cd0beea.png)

![imagen](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/3/23b88344ba3a5bde4fc55a71b9604b826b28caf2.png)

---

<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:** [February 8, 2023, 4:11pm UTC](https://forum.inductiveautomation.com/t/cause-of-logs-restarting-gateway-scripts/69584/2 "2023-02-08T16:11:32Z")

</div>

> [@FABRICIO\_VILATUNA](#):
>
> How can I prevent the Log: Restarting gateway scripts from executing?

You **cannot** prevent this. Gateway scripts _ **must** _ restart when a project is edited and saved.

In a tag change event, inspect the `initialChange` boolean in your logic to handle this case specially.

---

<div class="post-metadata">

**Author:** ![FABRICIO\_VILATUNA](https://avatars.discourse-cdn.com/v4/letter/f/4af34b/32.png) [@FABRICIO\_VILATUNA](https://forum.inductiveautomation.com/u/FABRICIO_VILATUNA)\
**Post date:** [February 8, 2023, 4:18pm UTC](https://forum.inductiveautomation.com/t/cause-of-logs-restarting-gateway-scripts/69584/3 "2023-02-08T16:18:13Z")

</div>

That is to say that when I make a change in any Gateway Script it would be restarted and therefore all the Gateway Scripts would be executed again?

---

<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:** [February 8, 2023, 4:19pm UTC](https://forum.inductiveautomation.com/t/cause-of-logs-restarting-gateway-scripts/69584/4 "2023-02-08T16:19:57Z")

</div>

Yes. When you save the project.

In v7.9, changes to shared scripts will make this happen in **all** projects. This is true even if you are using Staging mode, which only applies to Vision GUI resources.

In v8+, changes to scripts in inheritable projects will make this happen in all projects that inherit them.

---

<div class="post-metadata">

**Author:** ![chen\_zhe](https://avatars.discourse-cdn.com/v4/letter/c/c0e974/32.png) [@chen\_zhe](https://forum.inductiveautomation.com/u/chen_zhe)\
**Post date:** [December 11, 2023, 1:38am UTC](https://forum.inductiveautomation.com/t/cause-of-logs-restarting-gateway-scripts/69584/5 "2023-12-11T01:38:31Z")

</div>

HI pturmel  
this is my code

```auto
import time
total = 0
tempa = 0
oldtotal = 0
def calculate_downtime(start):    
    global total, tempa, start_time, end_time,oldtotal
    if start == False and tempa == 0:  
        start_time = time.time()  
        tempa = 1  
    elif start == True:
         tempa = 0   
    if tempa == 1:  
        end_time = time.time()  
        total = (end_time - start_time) + oldtotal
        return total/60
    elif tempa == 0:
         oldtotal = total
         return oldtotal/60

```

When I save the project, the global variables above are reset to zero. How can I prevent them from being reset to zero

---

<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:** [December 11, 2023, 2:12am UTC](https://forum.inductiveautomation.com/t/cause-of-logs-restarting-gateway-scripts/69584/6 "2023-12-11T02:12:26Z")

</div>

This is from another topic. The answer given in the other topic was to log your events to a database or historian and calculate from that history.

If you cannot do that, consider using datetime and 64-bit integer memory tags instead of script global variables to persistently hold your information.

Side note: Don't use python/jython standard libraries for things that Ignition and java provide, like dates and times, sockets, network protocols, and any form of character encoding/decoding. The jython libraries are trouble-prone, particularly for dates and times.

---

<div class="post-metadata">

**Author:** ![chen\_zhe](https://avatars.discourse-cdn.com/v4/letter/c/c0e974/32.png) [@chen\_zhe](https://forum.inductiveautomation.com/u/chen_zhe)\
**Post date:** [December 11, 2023, 5:40am UTC](https://forum.inductiveautomation.com/t/cause-of-logs-restarting-gateway-scripts/69584/7 "2023-12-11T05:40:16Z")

</div>

how can i use the memory tags，do I need to drag and drop it directly or do I need to use some command to use it?"

---

<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:** [December 11, 2023, 8:30am UTC](https://forum.inductiveautomation.com/t/cause-of-logs-restarting-gateway-scripts/69584/8 "2023-12-11T08:30:34Z")

</div>

@chen_zhe, please stop hijacking other threads.

- Maybe ask your question on an existing thread if it is relevant. This topic is about "Cause of logs". You have asked two questions on this thread - neither of which are on-topic.
- If you are not sure, then start a new thread and paste a link to any threads that might be related.
- Don't double-post.
- Don't ping other users looking for help. Apart from the IA staff, we are all volunteers. Most of the people you would want to contact read all the questions anyway and will reply if they have time and are interested in the problem.

Thanks.
