# Logstash Plugin Modifying Files

**URL:** <https://discuss.elastic.co/t/logstash-plugin-modifying-files/32705>\
**Category:** Logstash\
**Created:** [October 21, 2015, 5:34pm UTC](https://discuss.elastic.co/t/logstash-plugin-modifying-files/32705 "2015-10-21T17:34:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ahahtyler](https://avatars.discourse-cdn.com/v4/letter/a/6a8cbe/32.png) [@ahahtyler](https://discuss.elastic.co/u/ahahtyler)\
**Post date:** [October 21, 2015, 5:34pm UTC](https://discuss.elastic.co/t/logstash-plugin-modifying-files/32705/1 "2015-10-21T17:34:00Z")

</div>

Is it possible for a logstash plugin to modify files (delete/create) in a directory. The goal is to create a mutex.

I've created a Cloud Foundry plugin for logstash that uses the Cloud Foundry CLI. The CLI can only be used by a single process at a time, so if I have multiple logstash processes running on a single VM and they both receive a Cloud Foundry log, only one of them gets processed correctly.

I want to create a locking system so when one process starts to use the Cloud Foundry plugin, the other will wait until it's finished. My first go around is to have a file act as the key. However, I've been having a difficult time creating/deleting files from within the plugin code.

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [October 21, 2015, 8:16pm UTC](https://discuss.elastic.co/t/logstash-plugin-modifying-files/32705/2 "2015-10-21T20:16:50Z")

</div>

> Is it possible for a logstash plugin to modify files (delete/create) in a directory.

Yes. It's standard Ruby code. No operations are prevented by sandboxing or similar.

---

<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 6, 2017, 5:25am UTC](https://discuss.elastic.co/t/logstash-plugin-modifying-files/32705/3 "2017-07-06T05:25:50Z")

</div>


