# Creating a tag that returns the number of active scripts on a gateway

**URL:** <https://forum.inductiveautomation.com/t/creating-a-tag-that-returns-the-number-of-active-scripts-on-a-gateway/43181>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [February 9, 2021, 3:16pm UTC](https://forum.inductiveautomation.com/t/creating-a-tag-that-returns-the-number-of-active-scripts-on-a-gateway/43181 "2021-02-09T15:16:16Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![yves.morrissette](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/yves.morrissette/32/21307_2.png) [@yves.morrissette](https://forum.inductiveautomation.com/u/yves.morrissette)\
**Post date:** [February 9, 2021, 3:16pm UTC](https://forum.inductiveautomation.com/t/creating-a-tag-that-returns-the-number-of-active-scripts-on-a-gateway/43181/1 "2021-02-09T15:16:16Z")

</div>

Hi everyone,

Is there a way to create a tag that would return the number of active scripts running on a server?

[https://docs.inductiveautomation.com/display/DOC80/Diagnostics+-+Running+Scripts](https://docs.inductiveautomation.com/display/DOC80/Diagnostics+-+Running+Scripts)

I would like to create an alarm notification if the number is greater than 0 for a sustained amount of time.

Thanks!

---

<div class="post-metadata">

**Author:** ![rbachman](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/rbachman/32/43718_2.png) [@rbachman](https://forum.inductiveautomation.com/u/rbachman)\
**Post date:** [August 15, 2022, 4:46pm UTC](https://forum.inductiveautomation.com/t/creating-a-tag-that-returns-the-number-of-active-scripts-on-a-gateway/43181/2 "2022-08-15T16:46:03Z")

</div>

I would like to do this also. Does anyone know if this is possible?

---

<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:** [August 15, 2022, 4:50pm UTC](https://forum.inductiveautomation.com/t/creating-a-tag-that-returns-the-number-of-active-scripts-on-a-gateway/43181/3 "2022-08-15T16:50:14Z")

</div>

You could run this somewhere on the gateway and write the results to a tag using your mechanism of choice:

```auto
from com.inductiveautomation.ignition.common.script import ScriptManager
list(ScriptManager.executingScripts())

```

---

<div class="post-metadata">

**Author:** ![yves.morrissette](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/yves.morrissette/32/21307_2.png) [@yves.morrissette](https://forum.inductiveautomation.com/u/yves.morrissette)\
**Post date:** [August 16, 2022, 12:07pm UTC](https://forum.inductiveautomation.com/t/creating-a-tag-that-returns-the-number-of-active-scripts-on-a-gateway/43181/4 "2022-08-16T12:07:49Z")

</div>

I ran this in a script console directly on the gateway server, and all I got was an empty square bracket:

Jython 2.7.2 (uncontrolled:000000000000, Jan 25 2022, 14:39:15)  
[OpenJDK 64-Bit Server VM (Azul Systems, Inc.)] on java11.0.15

> > >

> > >

I tried multiple times. What is the result supposed to look like?

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [August 16, 2022, 12:15pm UTC](https://forum.inductiveautomation.com/t/creating-a-tag-that-returns-the-number-of-active-scripts-on-a-gateway/43181/5 "2022-08-16T12:15:57Z")

</div>

I wouldn’t expect this to work on the script console even in a designer on the same gateway server. You should set up a gateway message handler that runs the code and logs it/writes to a tag. You can then trigger that message handler via script console. But script console still runs as a designer/client scope, which is different from the gateway scope.

---

<div class="post-metadata">

**Author:** ![vrautomation](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/vrautomation/32/11155_2.png) [@vrautomation](https://forum.inductiveautomation.com/u/vrautomation)\
**Post date:** [September 21, 2022, 5:58pm UTC](https://forum.inductiveautomation.com/t/creating-a-tag-that-returns-the-number-of-active-scripts-on-a-gateway/43181/6 "2022-09-21T17:58:33Z")

</div>

I executed the scrip at the gateway level (inside a tag) and the result is written in a string memory tag.

I got this result:  
[com.inductiveautomation.ignition.common.script.ScriptManager$ExecutionInfo@3a1ca159, com.inductiveautomation.ignition.common.script.ScriptManager$ExecutionInfo@5286a490]

How do I know how much time each script is executing?

---

<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:** [September 21, 2022, 7:34pm UTC](https://forum.inductiveautomation.com/t/creating-a-tag-that-returns-the-number-of-active-scripts-on-a-gateway/43181/7 "2022-09-21T19:34:02Z")

</div>

[https://files.inductiveautomation.com/sdk/javadoc/ignition81/8.1.20/com/inductiveautomation/ignition/common/script/ScriptManager.ExecutionInfo.html](https://files.inductiveautomation.com/sdk/javadoc/ignition81/8.1.20/com/inductiveautomation/ignition/common/script/ScriptManager.ExecutionInfo.html)

ExecutionInfo is a class that contains a startTime field. You’ll have to do the math yourself to determine the duration.
