...
Linux Version
Download: forward_taskorder_logs_linux.job.xml
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
<?xml version="1.0" encoding="UTF-8" ?> <job title="Report Task History" process_class="agent_linux"> <params> <param name="history_results_directory" value="/home/js/history"/> </params> <script language="shell"><![CDATA[ pwsh -NoLogo -NonInteractive -Command '& { . $env:SCHEDULER_DATA/config/powershell/JobScheduler.PowerShell_profile.ps1; Import-Module $env:SCHEDULER_DATA/config/powershell/Modules/JobScheduler; Connect-JS -Url $JOCCockpitUrl -Credential $JOCCockpitCredential | Out-Null; # retrieve last history results if available if ( Test-Path -Path "$($env:SCHEDULER_PARAM_HISTORY_RESULTS_DIRECTORY)/order.history" -ErrorAction continue ) { $lastHistory = Import-Clixml -Path "$($env:SCHEDULER_PARAM_HISTORY_RESULTS_DIRECTORY)/order.history"; } else { $lastHistory = Get-JobSchedulerOrderHistory -RelativeDateFrom -8h | Sort-Object -Property startTime; } # Copy log files to target directory Get-JobSchedulerOrderHistory -DateFrom $lastHistory[0].startTime | Tee-Object -Variable lastHistory | Get-JobSchedulerOrderLog | Select-Object @{name="path"; expression={ "$env:SCHEDULER_PARAM_HISTORY_RESULTS_DIRECTORY/$(Get-Date $_.startTime -f 'yyyyMMdd-hhmmss')-$([io.path]::GetFileNameWithoutExtension($_.orderId)).log"}}, @{name="value"; expression={ $_.log }} | Set-Content; # store last history results to a file for later retrieval $lastHistory | Export-Clixml -Path "$env:SCHEDULER_PARAM_HISTORY_RESULTS_DIRECTORY/order.history"; Write-Output ".. logs forwarded to: $env:SCHEDULER_PARAM_HISTORY_RESULTS_DIRECTORY"; }' ]]></script> <run_time/> </job> </job> |
...