foam_sync.ps1 (LIFEBALANCE) 2025-06-19T14:11:15Z
This commit is contained in:
@ -12,17 +12,14 @@ $scriptName = (Get-Item $scriptPath).Name
|
|||||||
$taskName = 'FoamGitSync'
|
$taskName = 'FoamGitSync'
|
||||||
$taskDescription = "Periodically synchronizes the Git repository at $scriptDir using $scriptName."
|
$taskDescription = "Periodically synchronizes the Git repository at $scriptDir using $scriptName."
|
||||||
$frequencyMinutes = 2
|
$frequencyMinutes = 2
|
||||||
|
$timeLimitSeconds = 30
|
||||||
|
|
||||||
if (-not (Test-Path -Path $logDir)) {
|
if (-not (Test-Path -Path $logDir)) {
|
||||||
New-Item -ItemType Directory -Path $logDir -Force | Out-Null
|
New-Item -ItemType Directory -Path $logDir -Force | Out-Null
|
||||||
}
|
}
|
||||||
$logFilePath = Join-Path -Path $logDir -ChildPath "foam_sync.log"
|
|
||||||
|
|
||||||
Start-Transcript -Path $logFilePath -Append -IncludeInvocationHeader -Force
|
Start-Transcript -Path $logFilePath -Append -IncludeInvocationHeader -Force
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
|
||||||
Write-Host "Script: $scriptName at $scriptPath"
|
Write-Host "Script: $scriptName at $scriptPath"
|
||||||
Write-Host "Repository directory: $scriptDir"
|
Write-Host "Repository directory: $scriptDir"
|
||||||
Write-Host "Sync frequency: Every $frequencyMinutes minutes"
|
Write-Host "Sync frequency: Every $frequencyMinutes minutes"
|
||||||
@ -35,8 +32,7 @@ try {
|
|||||||
$action = New-ScheduledTaskAction -Execute "powershell.exe" -Argument $actionArgumentForRegistration
|
$action = New-ScheduledTaskAction -Execute "powershell.exe" -Argument $actionArgumentForRegistration
|
||||||
|
|
||||||
# Task settings
|
# Task settings
|
||||||
$taskExecutionTimeLimit = New-TimeSpan -Seconds 30
|
$settings = New-ScheduledTaskSettingsSet -ExecutionTimeLimit $(New-TimeSpan -Seconds $timeLimitSeconds)
|
||||||
$settings = New-ScheduledTaskSettingsSet -ExecutionTimeLimit $taskExecutionTimeLimit
|
|
||||||
|
|
||||||
# Check and configure the scheduled task
|
# Check and configure the scheduled task
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user