# Close Csv File when Logstash is run as a windows service

**URL:** <https://discuss.elastic.co/t/close-csv-file-when-logstash-is-run-as-a-windows-service/235363>\
**Category:** Logstash\
**Created:** [June 2, 2020, 3:13pm UTC](https://discuss.elastic.co/t/close-csv-file-when-logstash-is-run-as-a-windows-service/235363 "2020-06-02T15:13:52Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bender](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bender/32/47806_2.png) [@Bender](https://discuss.elastic.co/u/Bender)\
**Post date:** [June 2, 2020, 3:13pm UTC](https://discuss.elastic.co/t/close-csv-file-when-logstash-is-run-as-a-windows-service/235363/1 "2020-06-02T15:13:52Z")

</div>

Hello Community,

iam very new in this topic. I start a windows service via nssm.exe to observe a file for a csv to start the logstash.bat and specified config.

Now i have the problem that after the logstash is triggered. The csv file is still in use. How can i close the csv file after logstash is finished with the csv. Second question is where, and did i need additional plugins?

Where: In Config file or in arguments via nssm.exe?

best regards

Bernd

---

<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:** [June 2, 2020, 3:28pm UTC](https://discuss.elastic.co/t/close-csv-file-when-logstash-is-run-as-a-windows-service/235363/2 "2020-06-02T15:28:48Z")

</div>

If you are using a file input in tail mode then logstash will keep the file open and tail it forever. You may be able to use read mode. What does your configuration look like.

---

<div class="post-metadata">

**Author:** ![Bender](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bender/32/47806_2.png) [@Bender](https://discuss.elastic.co/u/Bender)\
**Post date:** [June 3, 2020, 7:12am UTC](https://discuss.elastic.co/t/close-csv-file-when-logstash-is-run-as-a-windows-service/235363/3 "2020-06-03T07:12:18Z")

</div>

> [@Badger](#):
>
> it forever. You may be

```auto
input {
	file {
		path => "Q:/DATA/Test/Logstash/*.csv"
		start_position => "beginning"
		sincedb_path => "Q:/DATA/Test/Logstash/sincedb"
	}
}
filter {
	csv {
		separator => ";"
		skip_header => "true"
		columns => ["testdata1","testdata2","Date"]	
	}

	
	date {
		match => ["Date","yyyyMMddHHmmss"]
		target => "Date"
	}
	
	
	
}
output {	
	elasticsearch {
        hosts => ["elastictest:9200"]
        index => "test"      
	}
}

```

---

<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:** [June 3, 2020, 10:57am UTC](https://discuss.elastic.co/t/close-csv-file-when-logstash-is-run-as-a-windows-service/235363/4 "2020-06-03T10:57:04Z")

</div>

OK, you are using tail mode, so logstash will keep the file open forever.

---

<div class="post-metadata">

**Author:** ![Bender](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bender/32/47806_2.png) [@Bender](https://discuss.elastic.co/u/Bender)\
**Post date:** [June 18, 2020, 8:50am UTC](https://discuss.elastic.co/t/close-csv-file-when-logstash-is-run-as-a-windows-service/235363/5 "2020-06-18T08:50:33Z")

</div>

thx solved i added close\_older

---

<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:** [July 16, 2020, 8:50am UTC](https://discuss.elastic.co/t/close-csv-file-when-logstash-is-run-as-a-windows-service/235363/6 "2020-07-16T08:50:45Z")

</div>

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