Does Tail.exe lock the files it reads?

Posted on 2009-02-23
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
    LVL 86

    Accepted Solution

    '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

    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

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

    Author Closing Comment

    Thank you for your quick response to my question.
    LVL 1

    Expert Comment

    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

    Live: Real-Time Solutions, Start Here

    Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

    Join & Write a Comment

    Suggested Solutions

    This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
    This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
    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.…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    745 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

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now