# How to automatically stop logstash process instance after its read the doc

**URL:** <https://discuss.elastic.co/t/how-to-automatically-stop-logstash-process-instance-after-its-read-the-doc/265343>\
**Category:** Logstash\
**Created:** [February 24, 2021, 1:20pm UTC](https://discuss.elastic.co/t/how-to-automatically-stop-logstash-process-instance-after-its-read-the-doc/265343 "2021-02-24T13:20:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rknd](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rknd/32/103882_2.png) [@rknd](https://discuss.elastic.co/u/rknd)\
**Post date:** [February 24, 2021, 1:20pm UTC](https://discuss.elastic.co/t/how-to-automatically-stop-logstash-process-instance-after-its-read-the-doc/265343/1 "2021-02-24T13:20:33Z")

</div>

I want to ask that, below is my code. With the below code logstash reads the file until its end. Then it is stops reading but process is still alive. I want that process stops when it finishes the reading. How can i do this ?

```auto
file {
        path => "directory/*.log"
        start_position => "beginning"
        mode => "read"
 
}

```

Thanks for answering

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [February 24, 2021, 2:33pm UTC](https://discuss.elastic.co/t/how-to-automatically-stop-logstash-process-instance-after-its-read-the-doc/265343/2 "2021-02-24T14:33:47Z")

</div>

A file input will continue to tail the file, waiting for additional log messages to be written to it. It will not terminate the process.

There are a few inputs that will terminate the logstash process when they finish reading. For example, if you cat the file into a stdin input then when it reaches EOF it will terminate logstash.

---

<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 24, 2021, 2:34pm UTC](https://discuss.elastic.co/t/how-to-automatically-stop-logstash-process-instance-after-its-read-the-doc/265343/3 "2021-03-24T14:34:35Z")

</div>

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