# Stop logstash after processing the file

**URL:** <https://discuss.elastic.co/t/stop-logstash-after-processing-the-file/84959>\
**Category:** Logstash\
**Created:** [May 8, 2017, 4:20pm UTC](https://discuss.elastic.co/t/stop-logstash-after-processing-the-file/84959 "2017-05-08T16:20:17Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![skairam](https://avatars.discourse-cdn.com/v4/letter/s/f17d59/32.png) [@skairam](https://discuss.elastic.co/u/skairam)\
**Post date:** [May 8, 2017, 4:20pm UTC](https://discuss.elastic.co/t/stop-logstash-after-processing-the-file/84959/1 "2017-05-08T16:20:17Z")

</div>

Hi all,

I have a shell script which will be triggered when ever a new file is arrived into a folder called inbound.  
logstash process needs to be started to read and load the file contents into elastic.

I am able to do the above steps but the logstash process is still in waiting mode. How can i safely exit the logstash process to mark the file loading is completed.

Regards  
KK

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [May 8, 2017, 7:42pm UTC](https://discuss.elastic.co/t/stop-logstash-after-processing-the-file/84959/2 "2017-05-08T19:42:28Z")

</div>

This has been covered here many times before. In short you have two options:

- Monitor the sincedb file to check when Logstash has reached EOF, then kill Logstash.
- Use the stdin input instead. Logstash will shut down by itself when stdin has been closed and all inputs has been processed. On the flip side, it Logstash dies for whatever reason you don't know how much it has processed.

But why do you need to start and stop Logstash on demand? Can't you let it run all the time and process files as they arrive?

---

<div class="post-metadata">

**Author:** ![skairam](https://avatars.discourse-cdn.com/v4/letter/s/f17d59/32.png) [@skairam](https://discuss.elastic.co/u/skairam)\
**Post date:** [May 9, 2017, 5:01pm UTC](https://discuss.elastic.co/t/stop-logstash-after-processing-the-file/84959/3 "2017-05-09T17:01:04Z")

</div>

THanks for your response. the reason why we want to stop and start te logstash on demand because, we receive the file from other system only once in a day. so, dont want to keep running this process for ever.

secondly, we want to move the data file to archives folder for audit purpose. so we have to know if logstash has completed the processing of the file or not.

Can you please provide any example script code for the 2 solutions that you have provided. thanks much.

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [May 9, 2017, 6:18pm UTC](https://discuss.elastic.co/t/stop-logstash-after-processing-the-file/84959/4 "2017-05-09T18:18:32Z")

</div>

I don't have time to provide complete examples, but I can answer specific questions you might have. Also, see [http://stackoverflow.com/questions/33143437/logstash-parsing-progress-bar](http://stackoverflow.com/questions/33143437/logstash-parsing-progress-bar) for details on how to know when Logstash is done processing a file.

---

<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 6, 2017, 6:31pm UTC](https://discuss.elastic.co/t/stop-logstash-after-processing-the-file/84959/5 "2017-06-06T18:31:57Z")

</div>

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