我想使用(以避免打开整个日志)Start-Job
同时监视(尾)多个日志文件。Get-Content file -Wait -Last 1
-Last 1
运行gc $file -Last 1 -Wait
只允许拖尾一个文件。把它包起来Start-Job -Scriptblock
立即辞职。
我有这样的想法。
Start-Job -Name srv1 -ScriptBlock {Get-Content "\\srv1\$log" -Wait -Last 1} | Select-String "matching some text only" | Out-File D:\autogrep.log}
Start-Job -Name srv2 -ScriptBlock {Get-Content "\\srv2\$log" -Wait -Last 1} | Select-String "matching some text only" | Out-File D:\autogrep.log}
Start-Job -Name srv3 -ScriptBlock {Get-Content "\\srv3\$log" -Wait -Last 1} | Select-String "matching some text only" | Out-File D:\autogrep.log}
Start-Job -Name srv4 -ScriptBlock {Get-Content "\\srv4\$log" -Wait -Last 1} | Select-String "matching some text only" | Out-File D:\autogrep.log}
Start-Job -Name srv5 -ScriptBlock {Get-Content "\\srv5\$log" -Wait -Last 1} | Select-String "matching some text only" | Out-File D:\autogrep.log}
任何建议如何解决这个问题?