# How to let filebeat process exit when service is stopped?

**URL:** <https://discuss.elastic.co/t/how-to-let-filebeat-process-exit-when-service-is-stopped/86270>\
**Category:** Beats\
**Tags:** filebeat\
**Created:** [May 18, 2017, 1:35pm UTC](https://discuss.elastic.co/t/how-to-let-filebeat-process-exit-when-service-is-stopped/86270 "2017-05-18T13:35:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tang](https://avatars.discourse-cdn.com/v4/letter/t/e8c25b/32.png) [@tang](https://discuss.elastic.co/u/tang)\
**Post date:** [May 18, 2017, 1:35pm UTC](https://discuss.elastic.co/t/how-to-let-filebeat-process-exit-when-service-is-stopped/86270/1 "2017-05-18T13:35:56Z")

</div>

my service writes to stdin every some seconds.  
If I stop service, thus stdin is closed, but filebeat process still works.  
I hope when stopping my service, filebeat stops its process also.  
How can I do that? many thanks.

filebeat's once flag don't work. because I have many EOFs when my service running.

filebeat version : 5.4

filebeat.prospectors:

- input\_type: stdin  
paths:
  - "-"  
close\_eof: true  
fields:  
mesos\_log\_stream: stdin  
output.logstash:  
hosts: ["[test.com:23121](http://test.com:23121)"]

---

<div class="post-metadata">

**Author:** ![steffens](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/steffens/32/79630_2.png) [@steffens](https://discuss.elastic.co/u/steffens)\
**Post date:** [May 18, 2017, 2:15pm UTC](https://discuss.elastic.co/t/how-to-let-filebeat-process-exit-when-service-is-stopped/86270/2 "2017-05-18T14:15:04Z")

</div>

have you tried to run filebeat with `-once` flag? You might want configure [shutdown\_timeout](https://www.elastic.co/guide/en/beats/filebeat/current/configuration-global-options.html#shutdown-timeout), giving filebeat a chance to publish the events though.

---

<div class="post-metadata">

**Author:** ![tang](https://avatars.discourse-cdn.com/v4/letter/t/e8c25b/32.png) [@tang](https://discuss.elastic.co/u/tang)\
**Post date:** [May 19, 2017, 10:22am UTC](https://discuss.elastic.co/t/how-to-let-filebeat-process-exit-when-service-is-stopped/86270/3 "2017-05-19T10:22:44Z")

</div>

I have tried once flag.  
but EOF is different from stdin has been closed.  
If my service will output many EOFs, then old filebeat process will be stopped, new process starts over and over when  
my service is still on.

what I hope is as follows:  
when my service is stopped, stdin is closed, filebeat will be closed then.

---

<div class="post-metadata">

**Author:** ![steffens](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/steffens/32/79630_2.png) [@steffens](https://discuss.elastic.co/u/steffens)\
**Post date:** [May 19, 2017, 11:34am UTC](https://discuss.elastic.co/t/how-to-let-filebeat-process-exit-when-service-is-stopped/86270/4 "2017-05-19T11:34:51Z")

</div>

home come you script can close stdout multiple times?

---

<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:** [June 16, 2017, 11:34am UTC](https://discuss.elastic.co/t/how-to-let-filebeat-process-exit-when-service-is-stopped/86270/5 "2017-06-16T11:34:59Z")

</div>

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