# Setup logstash to stop reading a file after some time

**URL:** <https://discuss.elastic.co/t/setup-logstash-to-stop-reading-a-file-after-some-time/273117>\
**Category:** Logstash\
**Created:** [May 16, 2021, 9:06pm UTC](https://discuss.elastic.co/t/setup-logstash-to-stop-reading-a-file-after-some-time/273117 "2021-05-16T21:06:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Amit\_Singh3](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/amit_singh3/32/48044_2.png) [@Amit\_Singh3](https://discuss.elastic.co/u/Amit_Singh3)\
**Post date:** [May 16, 2021, 9:06pm UTC](https://discuss.elastic.co/t/setup-logstash-to-stop-reading-a-file-after-some-time/273117/1 "2021-05-16T21:06:49Z")

</div>

We are using logstsash to read a folder to read logs, due to log rotation tons of files are being created in the folder, what if I want logstash to stop reading from a file if there is no new data in a file for 5 minutes.

---

<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:** [May 16, 2021, 10:33pm UTC](https://discuss.elastic.co/t/setup-logstash-to-stop-reading-a-file-after-some-time/273117/2 "2021-05-16T22:33:09Z")

</div>

If you mean you want logstash to stop monitoring a file if there is a gap of more than five minutes then that cannot be done. If you just want it to close the file then look at the close\_older option.

---

<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 13, 2021, 10:33pm UTC](https://discuss.elastic.co/t/setup-logstash-to-stop-reading-a-file-after-some-time/273117/3 "2021-06-13T22:33:15Z")

</div>

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