# Working of ES as a daemon

**URL:** <https://discuss.elastic.co/t/working-of-es-as-a-daemon/118528>\
**Category:** Elasticsearch\
**Created:** [February 5, 2018, 9:50pm UTC](https://discuss.elastic.co/t/working-of-es-as-a-daemon/118528 "2018-02-05T21:50:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![fhalde](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fhalde/32/21419_2.png) [@fhalde](https://discuss.elastic.co/u/fhalde)\
**Post date:** [February 5, 2018, 9:50pm UTC](https://discuss.elastic.co/t/working-of-es-as-a-daemon/118528/1 "2018-02-05T21:50:06Z")

</div>

Our cluster sizes are getting bigger and bigger [40-50machines] & there are times when we need to do a full cluster restart

It is really painful to log into each machines and restart ES processes running on them

For mitigating that, we were writing a daemon process in each machine that would be responsible for starting/stopping ES nodes on that machine thru a rest API [Java daemon]

But the problem we are facing is, whenever we spawn a ES process [./bin/elasticsearch -d] from the Java daemon, we are unable to get back the PID of the ES process. Can someone explain how ES as a daemon works?

We use RuntimeExec.exec for executing the script

---

<div class="post-metadata">

**Author:** ![rjernst](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rjernst/32/6363_2.png) [@rjernst](https://discuss.elastic.co/u/rjernst)\
**Post date:** [February 6, 2018, 12:45am UTC](https://discuss.elastic.co/t/working-of-es-as-a-daemon/118528/2 "2018-02-06T00:45:18Z")

</div>

The `-d` option means daemonize. Elasticsearch will write a pid file in that case. You can pass the pid file location with the `-p` option.

---

<div class="post-metadata">

**Author:** ![fhalde](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fhalde/32/21419_2.png) [@fhalde](https://discuss.elastic.co/u/fhalde)\
**Post date:** [February 6, 2018, 12:51am UTC](https://discuss.elastic.co/t/working-of-es-as-a-daemon/118528/3 "2018-02-06T00:51:17Z")

</div>

Awesome. you are a life saver. hope this helps

---

<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:** [March 6, 2018, 12:51am UTC](https://discuss.elastic.co/t/working-of-es-as-a-daemon/118528/4 "2018-03-06T00:51:20Z")

</div>

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