# Elasticsearch doesn't update pid file (and kibana does)

**URL:** <https://discuss.elastic.co/t/elasticsearch-doesnt-update-pid-file-and-kibana-does/200681>\
**Category:** Elasticsearch\
**Created:** [September 23, 2019, 11:20am UTC](https://discuss.elastic.co/t/elasticsearch-doesnt-update-pid-file-and-kibana-does/200681 "2019-09-23T11:20:03Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![yishain11](https://avatars.discourse-cdn.com/v4/letter/y/df705f/32.png) [@yishain11](https://discuss.elastic.co/u/yishain11)\
**Post date:** [September 23, 2019, 11:20am UTC](https://discuss.elastic.co/t/elasticsearch-doesnt-update-pid-file-and-kibana-does/200681/1 "2019-09-23T11:20:03Z")

</div>

Hi everyone!  
I have a setup of the elk stack (I don't use any beats or other members of the elastic stack) that start and stop not via deamon or system ctl, rather directly from the respective bin and scripts.  
When I start elastic or kibana, I need to find out what is the PID.

One way to achieve that is to use something like:

```
ps -ef | grep elasticsearch
ps -ef | grep kibana

```

The risk is that I assume that there are no folders/other processes with the words grep is looking for.

The second option I tried was to check the PID file. Both kibana and elastic generated PID file in this path ~/deployment/folder/path/logs/elastic(kibana).pid

But I noticed something strange:

Kibana updated its pid whenever I started/stoped it, and the pid was consistent between the first pid finding method and the second one.

In elastic, on the other hand, the pid file was not updated each time, the same number is stored in the file, and the ps method generated the correct pid.

Why does elastic does not update the pid file?  
Is there a place I can configure elastic to update the pid file?

I use elastic/kibana v6.2 with the default yml files.

Thanks!

---

<div class="post-metadata">

**Author:** ![Bernt\_Rostad](https://avatars.discourse-cdn.com/v4/letter/b/3ab097/32.png) [@Bernt\_Rostad](https://discuss.elastic.co/u/Bernt_Rostad)\
**Post date:** [September 23, 2019, 11:35am UTC](https://discuss.elastic.co/t/elasticsearch-doesnt-update-pid-file-and-kibana-does/200681/2 "2019-09-23T11:35:55Z")

</div>

> [@yishain11](#):
>
> rather directly from the respective bin and scripts.

How do you specify the PID directory?

I'm also running the bin scripts directly and specifies the PID file with the -p option like this:

`bin/elasticsearch -d -p /some/path/node_name.pid`

This works well for me in ES 6.8.

---

<div class="post-metadata">

**Author:** ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)\
**Post date:** [September 23, 2019, 12:05pm UTC](https://discuss.elastic.co/t/elasticsearch-doesnt-update-pid-file-and-kibana-does/200681/3 "2019-09-23T12:05:03Z")

</div>

You can get the PIDs of the nodes in an Elasticsearch cluster from its API:

```auto
GET /_cat/nodes?h=n,p&v

# n p
# node-1 45152
# node-0 45150
# node-2 45151
#

GET /_nodes/jvm?filter_path=nodes.*.jvm.pid

# {
# "nodes": {
# "libdruUFS8-O9_OCZGSj3Q": {
# "jvm": {
# "pid": 45151
# }
# },
# "vc5lpqI-QfeYqyx-H3y3kw": {
# "jvm": {
# "pid": 45152
# }
# },
# "JIoOZJ1YTAu9znnrEFOsqQ": {
# "jvm": {
# "pid": 45150
# }
# }
# }
# }

```

You can also use [node filters](https://www.elastic.co/guide/en/elasticsearch/reference/7.3/cluster.html#cluster-nodes) to request the PIDs of a filtered set of nodes, for instance the `_local` node only:

```auto
GET /_nodes/_local/jvm?filter_path=nodes.*.jvm.pid

# {
# "nodes": {
# "JIoOZJ1YTAu9znnrEFOsqQ": {
# "jvm": {
# "pid": 45150
# }
# }
# }
# }

```

---

<div class="post-metadata">

**Author:** ![yishain11](https://avatars.discourse-cdn.com/v4/letter/y/df705f/32.png) [@yishain11](https://discuss.elastic.co/u/yishain11)\
**Post date:** [September 23, 2019, 12:12pm UTC](https://discuss.elastic.co/t/elasticsearch-doesnt-update-pid-file-and-kibana-does/200681/4 "2019-09-23T12:12:07Z")

</div>

OK great, I will try that, but is there any way to just configure elastic to work with the pid file? Seems alot easier...

---

<div class="post-metadata">

**Author:** ![yishain11](https://avatars.discourse-cdn.com/v4/letter/y/df705f/32.png) [@yishain11](https://discuss.elastic.co/u/yishain11)\
**Post date:** [September 23, 2019, 12:21pm UTC](https://discuss.elastic.co/t/elasticsearch-doesnt-update-pid-file-and-kibana-does/200681/5 "2019-09-23T12:21:37Z")

</div>

I read that on the elastic docs, but for some reason, no file is generated. Plus, I would need to run this script every time I start elastic, and I would rather that elastic will handle this automaticly.

---

<div class="post-metadata">

**Author:** ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)\
**Post date:** [September 23, 2019, 12:21pm UTC](https://discuss.elastic.co/t/elasticsearch-doesnt-update-pid-file-and-kibana-does/200681/6 "2019-09-23T12:21:40Z")

</div>

I tried adding this to my `elasticsearch.yml`:

`pidfile: /path/to/pidfile`

With this setting, the file was created anew with the correct contents each time Elasticsearch was started, and removed when Elasticsearch stopped. I was using 7.3.0 but this looks to be quite an old feature.

---

<div class="post-metadata">

**Author:** ![yishain11](https://avatars.discourse-cdn.com/v4/letter/y/df705f/32.png) [@yishain11](https://discuss.elastic.co/u/yishain11)\
**Post date:** [September 23, 2019, 12:24pm UTC](https://discuss.elastic.co/t/elasticsearch-doesnt-update-pid-file-and-kibana-does/200681/7 "2019-09-23T12:24:43Z")

</div>

It works.  
Thanks to you and to @Bernt_Rostad for you time

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 21, 2019, 12:24pm UTC](https://discuss.elastic.co/t/elasticsearch-doesnt-update-pid-file-and-kibana-does/200681/8 "2019-10-21T12:24:47Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
