【发布时间】:2021-10-24 06:43:45
【问题描述】:
我有来自带有 windows 终端和命令的 wamp 服务器的监控日志
Get-Content "C:\wamp64\logs\php_error.log" -Wait
但由于某种原因,现在停止工作,我找不到问题所在。
当我启动 PowerShell 和命令时,我可以看到 php_error.log 的内容,但是当 wamp 开始在 php_error.log 中写入/追加新内容时,我有这个错误
Get-Content : The process cannot access the file because another process has locked a portion of the file.
At line:1 char:1
+ Get-Content "C:\wamp64\logs\php_error.log" -Wait
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ReadError: (C:\wamp64\logs\php_error.log:String) [Get-Content], IOException
+ FullyQualifiedErrorId : GetContentReaderIOError,Microsoft.PowerShell.Commands.GetContentCommand
【问题讨论】:
-
关闭 WinAmp,它应该可以正常工作。
-
不是 Winamp,是 Wamp 服务器
-
因为制作文件的应用程序已锁定文件......你被困住了。要么将调用包装在 try-catch 块中,要么使用其他错误处理方法。
标签: powershell wamp