# How to rotate files in output plugin

**URL:** <https://discuss.elastic.co/t/how-to-rotate-files-in-output-plugin/224698>\
**Category:** Logstash\
**Created:** [March 23, 2020, 5:13pm UTC](https://discuss.elastic.co/t/how-to-rotate-files-in-output-plugin/224698 "2020-03-23T17:13:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![akhilsharma.in](https://avatars.discourse-cdn.com/v4/letter/a/6f9a4e/32.png) [@akhilsharma.in](https://discuss.elastic.co/u/akhilsharma.in)\
**Post date:** [March 23, 2020, 5:13pm UTC](https://discuss.elastic.co/t/how-to-rotate-files-in-output-plugin/224698/1 "2020-03-23T17:13:41Z")

</div>

Team,

I'm writing an output conf file and I want the output to be stored in a file. My conf file will get events once a day. I want when my conf file gets data tomorrow, it replaces the file of previous day to prevent filling up of disk space. is there any way to rotate files or replace files. write\_behavior replaces events but I want to replace file.

Thanks  
akhil

---

<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:** [March 23, 2020, 7:03pm UTC](https://discuss.elastic.co/t/how-to-rotate-files-in-output-plugin/224698/2 "2020-03-23T19:03:20Z")

</div>

You might be able to write a ruby filter that checks if the file has today's date and removes it if it does. That would happen on every event, which adds some overhead. I do not think the file output can do that.

---

<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:** [April 20, 2020, 7:03pm UTC](https://discuss.elastic.co/t/how-to-rotate-files-in-output-plugin/224698/3 "2020-04-20T19:03:25Z")

</div>

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