Skip to content

Commit e5a9167

Browse files
Merge pull request #67 from leojonathanoh/fix/fix-copytruncate-to-work-when-another-process-has-an-read-lock-on-the-log-file
Fix: Fix `copytruncate` to work when another process has an read lock on the log file
2 parents 6bb4ef4 + 9a42543 commit e5a9167

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/Log-Rotate/classes/New-LogObject.ps1

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ function New-LogObject {
2929
if ($copytruncate) {
3030
Write-Verbose "Truncating $my_fullname"
3131
if (!$WhatIf) {
32-
Clear-Content $my_fullname
32+
# Truncate the file
33+
[IO.File]::WriteAllText($my_fullname, '')
3334
}
3435
}else {
3536
Write-Verbose "Not truncating $my_fullname"

0 commit comments

Comments
 (0)