# Hourly log rotation?

**URL:** <https://discuss.elastic.co/t/hourly-log-rotation/106958>\
**Category:** Logstash\
**Created:** [November 9, 2017, 4:09am UTC](https://discuss.elastic.co/t/hourly-log-rotation/106958 "2017-11-09T04:09:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sjaak01](https://avatars.discourse-cdn.com/v4/letter/s/73ab20/32.png) [@Sjaak01](https://discuss.elastic.co/u/Sjaak01)\
**Post date:** [November 9, 2017, 4:09am UTC](https://discuss.elastic.co/t/hourly-log-rotation/106958/1 "2017-11-09T04:09:03Z")

</div>

Hi,

Is it possible to create hourly log files?

```auto
output {
 if [type] == "netflow" {
 file {
   path => "/home/test/Desktop/test/netflow-%{+YYYY-MM-dd-HH}.gz"
   gzip => true
 }
}
}
```

Creates a properly timestamped file when I start logstash but doesn't create a new file every hour.

---

<div class="post-metadata">

**Author:** ![theuntergeek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/theuntergeek/32/44961_2.png) [@theuntergeek](https://discuss.elastic.co/u/theuntergeek)\
**Post date:** [November 10, 2017, 3:33pm UTC](https://discuss.elastic.co/t/hourly-log-rotation/106958/2 "2017-11-10T15:33:58Z")

</div>

Logstash won't create a file if there isn't new data, or if the `@timestamp` field has older data. It doesn't just say, "oh, the hour has rolled over, I should create a new file." It writes events out, as they are received by the file output plugin, to a file whose name is partially derived from the date value in the `@timestamp` field in this case.

I can't see if you're using the `date` filter to parse timestamps, but that can affect things, as the `%{+YYYY-MM-dd-HH}` string reads those values from `@timestamp`.

---

<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:** [December 8, 2017, 3:34pm UTC](https://discuss.elastic.co/t/hourly-log-rotation/106958/3 "2017-12-08T15:34:06Z")

</div>

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