# File not closed with JDBC input and CSV output

**URL:** <https://discuss.elastic.co/t/file-not-closed-with-jdbc-input-and-csv-output/180566>\
**Category:** Logstash\
**Created:** [May 10, 2019, 1:19pm UTC](https://discuss.elastic.co/t/file-not-closed-with-jdbc-input-and-csv-output/180566 "2019-05-10T13:19:16Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![romariol](https://avatars.discourse-cdn.com/v4/letter/r/97f17d/32.png) [@romariol](https://discuss.elastic.co/u/romariol)\
**Post date:** [May 10, 2019, 1:19pm UTC](https://discuss.elastic.co/t/file-not-closed-with-jdbc-input-and-csv-output/180566/1 "2019-05-10T13:19:16Z")

</div>

Hi,

I'm using a JDBC input to fetch data from a specific table. I want to put this data in a new file. For this I'm using the CSV output. What I'm seeing, is that the file remains open. I want this file to be closed, because after the creation of the CSV file, I want to place it into a different endpoint (like a blob storage). Is there a way to do this? My conf looks like this:

```
input {
  jdbc {
    jdbc_driver_library => "/driver/mssql-jdbc-7.2.2.jre8.jar"
    jdbc_driver_class => "com.microsoft.sqlserver.jdbc.SQLServerDriver"
    jdbc_connection_string => "jdbc:sqlserver://xxxxx\xxxx;database=xxxx;user=xxxxx;	password=xxxxxx"
jdbc_user => nil
schedule => "16 15 * * *"
statement => "SELECT * from [dbo].[yyyyyy]
    }
}

filter {

mutate {
	add_field => {"filename" => "%{+YYYY-MM-dd}" }
}

}

output {
csv {
    path => "zzz-yyyy-%{filename}.csv"
	fields => ["@timestamp","seq_num","delete_session_id","create_user"]
}
}

```

Thanks

---

<div class="post-metadata">

**Author:** ![elasticforme](https://avatars.discourse-cdn.com/v4/letter/e/f05b48/32.png) [@elasticforme](https://discuss.elastic.co/u/elasticforme)\
**Post date:** [May 10, 2019, 2:28pm UTC](https://discuss.elastic.co/t/file-not-closed-with-jdbc-input-and-csv-output/180566/2 "2019-05-10T14:28:10Z")

</div>

This is something different requirement.  
you can put output from mysql straight to csv file. why use logstash.

anyway how do you know that this file remains open?

---

<div class="post-metadata">

**Author:** ![romariol](https://avatars.discourse-cdn.com/v4/letter/r/97f17d/32.png) [@romariol](https://discuss.elastic.co/u/romariol)\
**Post date:** [May 10, 2019, 2:33pm UTC](https://discuss.elastic.co/t/file-not-closed-with-jdbc-input-and-csv-output/180566/3 "2019-05-10T14:33:59Z")

</div>

I know, but we want to maintain this ingesting via Logstash and not via MSSQL. What I see is if I run a seperate script, the file is still locked.

---

<div class="post-metadata">

**Author:** ![elasticforme](https://avatars.discourse-cdn.com/v4/letter/e/f05b48/32.png) [@elasticforme](https://discuss.elastic.co/u/elasticforme)\
**Post date:** [May 10, 2019, 3:29pm UTC](https://discuss.elastic.co/t/file-not-closed-with-jdbc-input-and-csv-output/180566/4 "2019-05-10T15:29:56Z")

</div>

I don't see any option for close in output-csv section.

[https://www.elastic.co/guide/en/logstash/current/plugins-outputs-csv.html#plugins-outputs-csv-csv\_options](https://www.elastic.co/guide/en/logstash/current/plugins-outputs-csv.html#plugins-outputs-csv-csv_options)

---

<div class="post-metadata">

**Author:** ![romariol](https://avatars.discourse-cdn.com/v4/letter/r/97f17d/32.png) [@romariol](https://discuss.elastic.co/u/romariol)\
**Post date:** [May 13, 2019, 7:42am UTC](https://discuss.elastic.co/t/file-not-closed-with-jdbc-input-and-csv-output/180566/5 "2019-05-13T07:42:55Z")

</div>

No exactly. What I do see now is that the file closes based on the scheduler cron. So lets say you've set it to "\* \* \* \* \*", the file will close after each next write actions. If you would run the cron every day, that would mean that the file remains open for an extremely long time.

---

<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 10, 2019, 7:43am UTC](https://discuss.elastic.co/t/file-not-closed-with-jdbc-input-and-csv-output/180566/6 "2019-06-10T07:43:07Z")

</div>

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