# Return the PID used for the Ignition service in Linux install?

**URL:** <https://forum.inductiveautomation.com/t/return-the-pid-used-for-the-ignition-service-in-linux-install/60945>\
**Category:** Ignition\
**Created:** [June 20, 2022, 8:17am UTC](https://forum.inductiveautomation.com/t/return-the-pid-used-for-the-ignition-service-in-linux-install/60945 "2022-06-20T08:17:28Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![richardNZ15](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/richardnz15/32/33373_2.png) [@richardNZ15](https://forum.inductiveautomation.com/u/richardNZ15)\
**Post date:** [June 20, 2022, 8:17am UTC](https://forum.inductiveautomation.com/t/return-the-pid-used-for-the-ignition-service-in-linux-install/60945/1 "2022-06-20T08:17:28Z")

</div>

Is it possible to use system.util.execute or some other wizardry to return the process ID that the Ignition gateway is running under, in the underlying linux installation.  
For reference i am running Ignition on an Ubuntu VM.  
Currently i can extract this using “top” command in Ubuntu and identify the PID as follows:

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

So in this case it is 1421.

Also, can anything be done to name it something more useful than just “Java”?

I need this for… reasons. Namely trying to run a shell script to start a Java Flight Recording to identify gateway performance issues. Automatically. Similar to how a Thread Dump would be request when gateway CPU / RAM is going higher than expected.

I’ve managed to execute my shell script automatically which is nice, but currently the PID is hardcoded as 1421, which will not be so nice after the service / VM restarts.

---

<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:** [June 20, 2022, 1:00pm UTC](https://forum.inductiveautomation.com/t/return-the-pid-used-for-the-ignition-service-in-linux-install/60945/2 "2022-06-20T13:00:28Z")

</div>

While Ignition is running there should be an `Ignition-Gateway.pid` file or something like that in the directory Ignition is installed and running from.

---

<div class="post-metadata">

**Author:** ![Kevin.Collins](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.collins/32/13497_2.png) [@Kevin.Collins](https://forum.inductiveautomation.com/u/Kevin.Collins)\
**Post date:** [June 20, 2022, 1:05pm UTC](https://forum.inductiveautomation.com/t/return-the-pid-used-for-the-ignition-service-in-linux-install/60945/3 "2022-06-20T13:05:23Z")

</div>

When the service starts, there will be a file that contains the PID of the Java Service Wrapper:

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

From there you should be able to use `pgrep -P $(cat Ignition-Gateway.pid)` to return the java process ID:

 ![Screen Shot 2022-06-20 at 8.04.18 AM](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/4/94a87e969a6e82a61a2f637e3adbb93b25973f43.png)

---

<div class="post-metadata">

**Author:** ![richardNZ15](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/richardnz15/32/33373_2.png) [@richardNZ15](https://forum.inductiveautomation.com/u/richardNZ15)\
**Post date:** [June 20, 2022, 8:16pm UTC](https://forum.inductiveautomation.com/t/return-the-pid-used-for-the-ignition-service-in-linux-install/60945/4 "2022-06-20T20:16:46Z")

</div>

Ah perfect, thank you. Learn something new every day.

But we can’t return anything from system.util.execute, so is there a way to get a value from a command line script into Ignition?

---

<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:** [June 20, 2022, 9:10pm UTC](https://forum.inductiveautomation.com/t/return-the-pid-used-for-the-ignition-service-in-linux-install/60945/5 "2022-06-20T21:10:30Z")

</div>

See this topic and Paul's linked topic within it:

> [@Establishing SSH Connection from Ignition and executing commands & Python](https://forum.inductiveautomation.com/t/establishing-ssh-connection-from-ignition-and-executing-commands-python/60397/2):
>
> To run python externally, you need no libraries locally. You need them wherever python will run. In Ignition, I would use java’s normal classes (starting with [ProcessBuilder](https://docs.oracle.com/javase/8/docs/api/java/lang/ProcessBuilder.html)) to spawn your platform’s ssh executable with suitable parameters (to connect to the remote system and launch your script), with a stream attached to the process’ stdout. Parse/decode that stream to get your result. Use SSH keys to avoid any prompts while connecting. I recommend arranging for the selected key to only al…

---

<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 21, 2022, 3:18pm UTC](https://forum.inductiveautomation.com/t/return-the-pid-used-for-the-ignition-service-in-linux-install/60945/6 "2022-06-21T15:18:20Z")

</div>

Perhaps:

```python
from java.lang import ProcessHandle
pid = ProcessHandle.current().pid()

```

---

<div class="post-metadata">

**Author:** ![richardNZ15](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/richardnz15/32/33373_2.png) [@richardNZ15](https://forum.inductiveautomation.com/u/richardNZ15)\
**Post date:** [June 21, 2022, 9:40pm UTC](https://forum.inductiveautomation.com/t/return-the-pid-used-for-the-ignition-service-in-linux-install/60945/7 "2022-06-21T21:40:49Z")

</div>

Lovely, that worked perfectly! Awesome stuff.
