View the log files that the script or RPA outputs in real time with the Get-Content
option in PowerShell.Sometimes, the script and RPA terminate abnormally due to the error of not opening the log file, and my colleagues say that it is because I open the file with Get-Content
, but I don't think Get-Content
will lock the file exclusively like UNIX tail
.However, no supporting information has been found at this time.
PowerShell is open-source, so I think the source will eventually solve it, but it's much less powerful to get to the destination.Do you have any PowerShell documentation (or information that I misunderstood that Get-Content
is locked exclusively)?
By default, fopen()
used by both UNIX and Windows in file opening is not exclusive, and no exclusivity is provided by standard (there seems to be a glibc extension).
Separately, however, the CreateFile()
(historically open files with this API) is a default exclusion specification that allows shared access if necessary.Additionally, it is divided into read and write permissions.
Even if the Get-Content-Wait
side does not exclude and allows shared access, the lock conflicts and fails to open the file if the write program excludes CreateFile()
by calling it roughly with the default argument.
I'm not confident about the PowerShell source code, but around here FileShare.ReadWrite I feel like I'm specifying permission to read or write.
© 2024 OneMinuteCode. All rights reserved.