diff --git a/foam_sync.ps1 b/foam_sync.ps1 index 7cf8018..a95eff7 100644 --- a/foam_sync.ps1 +++ b/foam_sync.ps1 @@ -12,17 +12,14 @@ $scriptName = (Get-Item $scriptPath).Name $taskName = 'FoamGitSync' $taskDescription = "Periodically synchronizes the Git repository at $scriptDir using $scriptName." $frequencyMinutes = 2 +$timeLimitSeconds = 30 if (-not (Test-Path -Path $logDir)) { 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 try { - - Write-Host "Script: $scriptName at $scriptPath" Write-Host "Repository directory: $scriptDir" Write-Host "Sync frequency: Every $frequencyMinutes minutes" @@ -35,8 +32,7 @@ try { $action = New-ScheduledTaskAction -Execute "powershell.exe" -Argument $actionArgumentForRegistration # Task settings - $taskExecutionTimeLimit = New-TimeSpan -Seconds 30 - $settings = New-ScheduledTaskSettingsSet -ExecutionTimeLimit $taskExecutionTimeLimit + $settings = New-ScheduledTaskSettingsSet -ExecutionTimeLimit $(New-TimeSpan -Seconds $timeLimitSeconds) # Check and configure the scheduled task try {