# Filebeats to read locked file

**URL:** <https://discuss.elastic.co/t/filebeats-to-read-locked-file/102826>\
**Category:** Beats\
**Tags:** filebeat\
**Created:** [October 5, 2017, 10:23am UTC](https://discuss.elastic.co/t/filebeats-to-read-locked-file/102826 "2017-10-05T10:23:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Parthgandhi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/parthgandhi/32/22742_2.png) [@Parthgandhi](https://discuss.elastic.co/u/Parthgandhi)\
**Post date:** [October 5, 2017, 10:23am UTC](https://discuss.elastic.co/t/filebeats-to-read-locked-file/102826/1 "2017-10-05T10:23:32Z")

</div>

Hi,  
I have an application which continuously writes to a log file and locks it while it is writing the data. I need to use filebeats to get the logs from the file to ElasticSearch in Real Time. Can filebeat ship such data from such a locked file? Also does filebeat lock the files while collecting and shipping the data.  
Thanks,  
Parth

---

<div class="post-metadata">

**Author:** ![kvch](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kvch/32/72058_2.png) [@kvch](https://discuss.elastic.co/u/kvch)\
**Post date:** [October 5, 2017, 7:17pm UTC](https://discuss.elastic.co/t/filebeats-to-read-locked-file/102826/2 "2017-10-05T19:17:05Z")

</div>

Filebeat does not lock files while reading.  
Do you run your application on UNIX or Windows? Because on UNIX file locks between processes are advisory. So in that case FB can read from those locked files.

---

<div class="post-metadata">

**Author:** ![Parthgandhi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/parthgandhi/32/22742_2.png) [@Parthgandhi](https://discuss.elastic.co/u/Parthgandhi)\
**Post date:** [October 6, 2017, 4:54am UTC](https://discuss.elastic.co/t/filebeats-to-read-locked-file/102826/3 "2017-10-06T04:54:13Z")

</div>

The application is running on Windows.

---

<div class="post-metadata">

**Author:** ![andrewkroh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrewkroh/32/3784_2.png) [@andrewkroh](https://discuss.elastic.co/u/andrewkroh)\
**Post date:** [October 6, 2017, 3:57pm UTC](https://discuss.elastic.co/t/filebeats-to-read-locked-file/102826/4 "2017-10-06T15:57:44Z")

</div>

Filebeat will only be able to read from the file if the application writing to it has allowed shared read access to file.

> [@Filebeat locking files](https://discuss.elastic.co/t/filebeat-locking-files/70501/2):
>
> Filebeat does not lock files. It [opens](https://github.com/elastic/beats/blob/11499e6c825618601adb801b9623fbfe0962d7fe/filebeat/input/file/file_windows.go#L93-L95) the file for reading only. And it specifies that the file can be read, written, and deleted by other applications while it has it open. It sounds like the thing that is trying to access the file is requesting exclusive access which it cannot get. It needs to allow other applications to read the file (FILE\_SHARE\_READ) when it opens the file.

---

<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:** [November 3, 2017, 3:57pm UTC](https://discuss.elastic.co/t/filebeats-to-read-locked-file/102826/5 "2017-11-03T15:57:49Z")

</div>

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