# Filebeat locking files

**URL:** <https://discuss.elastic.co/t/filebeat-locking-files/70501>\
**Category:** Beats\
**Tags:** filebeat\
**Created:** [January 4, 2017, 1:52am UTC](https://discuss.elastic.co/t/filebeat-locking-files/70501 "2017-01-04T01:52:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Prathap\_Reddy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/prathap_reddy/32/14291_2.png) [@Prathap\_Reddy](https://discuss.elastic.co/u/Prathap_Reddy)\
**Post date:** [January 4, 2017, 1:52am UTC](https://discuss.elastic.co/t/filebeat-locking-files/70501/1 "2017-01-04T01:52:13Z")

</div>

Hi,

I installed filebeat to monitor logs. Below are the environment details:

OS: windows 7  
filebeat version: 5.1.1

## Config Details

Prospectors config:

- input\_type: log  
paths:
  - C:\myfiles\ELKStack\Learning\*.log  
ignore\_older: 5m  
force\_close\_files: true  
scan\_frequency: 2s  
close\_inactive: 1m

output.file:  
path: "C:\myfiles\ELKStack\Output"  
filename: filebeatout.txt

I am using powershell script to generate log file:  
Add-content -path C:\myfiles\ELKStack\Learning\filebeattest.log "$(Get-Date) - This is log message $count"

## Issue:

Filebeat locks log file and powershell script is generating below error while writing to log:  
The process cannot access the file 'C:\myfiles\ELKStack\Learning\filebeattest.log' because it is being used by another process.

If filebeat continues to lock the file how can other processes access it? How to resolve the issue?

Thanks,  
prat

---

<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:** [January 4, 2017, 3:03am UTC](https://discuss.elastic.co/t/filebeat-locking-files/70501/2 "2017-01-04T03:03:15Z")

</div>

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:** ![Prathap\_Reddy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/prathap_reddy/32/14291_2.png) [@Prathap\_Reddy](https://discuss.elastic.co/u/Prathap_Reddy)\
**Post date:** [January 4, 2017, 3:27am UTC](https://discuss.elastic.co/t/filebeat-locking-files/70501/3 "2017-01-04T03:27:39Z")

</div>

Thanks for reply.

I validated with different application which opened the file with read  
share rights. It's working now.

Thanks,  
Prathap

---

<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:** [February 1, 2017, 3:27am UTC](https://discuss.elastic.co/t/filebeat-locking-files/70501/4 "2017-02-01T03:27:40Z")

</div>

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