Does Tail.exe lock the files it reads?

Posted on 2009-02-23
Medium Priority
Last Modified: 2013-12-03
We are having an issue with log files not updating.  One of the guys is using Tail.exe from Microsoft to read a specified number of lines from the bottom of the log file.    Since I don't have the code behind the tail.exe, it's difficult to know how file locking may be affecting updating the log files.  

How does tail.exe work with file locking?  If tail.exe is called multiple times for the same log file, would that keep the log file from updating because it's locked?  Thanks!
Question by:CynthiaZCar
  • 2
  • 2
LVL 86

Accepted Solution

jkr earned 1000 total points
ID: 23712935
'tail.exe' does not lock the files it reads - simply because in that case, a 'tail -f somefile.log' (where another process writes to 'somefile.log') would not work, locking in fact would defeat the whole purpose. So you can safely assume that there is no locking involved.

Author Comment

ID: 23713495
I agree that calling tail.exe -f somefile.log would defeat the purpose of tail.  However, they are not using tail.exe -f somefile.log.  They are refreshing - looping through the call to the logfile with just tail and the number of lines to show at 1-2 second intervals - almost a constant refresh.  What we're seeing is that when the refresh is turned on - through the GUI - the logfile stops updating - as though it's locked.
LVL 86

Expert Comment

ID: 23713556
Then I'd rather go for 'tail -f' instead of looping...

Author Closing Comment

ID: 31550108
Thank you for your quick response to my question.

Expert Comment

ID: 24960296
The correct answer to this question is, "Yes".  Tail.exe does in fact place at least a partial lock on the file.  For proof, try tail -f mylog.log and then try to delete or rename the log file.  You will get an error that the file is being used by another person or process.

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question