# How to recycle the file after reading with logstash-input-file plugin

**URL:** <https://discuss.elastic.co/t/how-to-recycle-the-file-after-reading-with-logstash-input-file-plugin/365586>\
**Category:** Logstash\
**Created:** [August 27, 2024, 3:55am UTC](https://discuss.elastic.co/t/how-to-recycle-the-file-after-reading-with-logstash-input-file-plugin/365586 "2024-08-27T03:55:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![chun](https://avatars.discourse-cdn.com/v4/letter/c/a87d85/32.png) [@chun](https://discuss.elastic.co/u/chun)\
**Post date:** [August 27, 2024, 3:55am UTC](https://discuss.elastic.co/t/how-to-recycle-the-file-after-reading-with-logstash-input-file-plugin/365586/1 "2024-08-27T03:55:44Z")

</div>

Hi,  
I have a logstash configuration as below. I'm expecting the json file is moved to archive path when reading is completed, but the json file is always there, and archive path is empty. Do I miss out anything in configuration?

```auto
input{
	
	file {
		mode => "read"
		path => ["c:/EDM/tools/dremio_dashboard/sys_jobs_recent.json"]
		file_completed_action => "log_and_delete"
		file_completed_log_path => "c:/EDM/tools/dremio_dashboard/archive"
		sincedb_clean_after => "1 day"
		start_position => "beginning"
		stat_interval => "1 hour"
		codec => json
	}
}

filter {
}

output {
 
  stdout {
    codec => rubydebug {}
  }
  elasticsearch {
	hosts => ["http://localhost:9200"]
	index => "dremio_sys_jobs_recent"
	ilm_enabled => "true"
	ilm_rollover_alias => "dremio_sys_jobs_data"
	ilm_policy => "dremio_policy"
  }	
}

```

---

<div class="post-metadata">

**Author:** ![Alex\_Salgado-Elastic](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alex_salgado-elastic/32/103081_2.png) [@Alex\_Salgado-Elastic](https://discuss.elastic.co/u/Alex_Salgado-Elastic)\
**Post date:** [August 27, 2024, 11:18am UTC](https://discuss.elastic.co/t/how-to-recycle-the-file-after-reading-with-logstash-input-file-plugin/365586/2 "2024-08-27T11:18:09Z")

</div>

Hi @chun,

You are using the `log_and_delete` configuration. This option is designed to delete the file after processing, but it will not move the file to another location.

Link: [File input plugin | Logstash Reference [8.15] | Elastic](https://www.elastic.co/guide/en/logstash/current/plugins-inputs-file.html)

---

<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:** [August 27, 2024, 12:53pm UTC](https://discuss.elastic.co/t/how-to-recycle-the-file-after-reading-with-logstash-input-file-plugin/365586/3 "2024-08-27T12:53:50Z")

</div>

> [@chun](#):
>
> I'm expecting the json file is moved to archive path when reading is completed, but the json file is always there, and archive path is empty. Do I miss out anything in configuration?

The file input expects to write log entries to the file specified by `file_completed_log_path`. If it points to a directory instead of a file then the `path` file is read, but it is not deleted and the action is not logged.

---

<div class="post-metadata">

**Author:** ![chun](https://avatars.discourse-cdn.com/v4/letter/c/a87d85/32.png) [@chun](https://discuss.elastic.co/u/chun)\
**Post date:** [August 28, 2024, 4:23am UTC](https://discuss.elastic.co/t/how-to-recycle-the-file-after-reading-with-logstash-input-file-plugin/365586/4 "2024-08-28T04:23:15Z")

</div>

Yes, the file is deleted after I change file\_completed\_log\_path point to a log file. Thanks so much!
