10.3 and 3.1 How to Truncate AppServer Broker and Server Logs Online
Problem
Is it possible to truncate an AppServer broker and server log online in Windows?
Solution
Yes, it is possible to use the following MS-Power shell script to truncate the log file using the command:
powershell -ExecutionPolicy ByPass -File c:\tools\cut.ps1
where cut.ps1 is the PowerShell script below (also attached).
Example:
powershell -ExecutionPolicy ByPass -File c:\tools\cut.ps1 asbroker1.server.log
# POWERSHELL SCRIPT: cut.ps1
param( [string]$Srcfile )
If ( $Srcfile -eq '' ) {
Write-Host
Write-Host 'Cut.ps1, Version 1.01'
Write-Host 'Cut content of a text file'
Write-Host
Write-Host 'Usage: .\cut.PS1 \Srcfile'
Write-Host
Write-Host 'Where: Srcfile is the file to be cut'
Write-Host
}
Else {
$newlines = @()
foreach ($line in $lines) {
$newlines= '--- Cut ! ---' + [DateTime]::Now.ToString('yyyy-MM-dd@HH:mm:ss')
}
$newlines | out-file -Force -Encoding ASCII $Srcfile
}