同步最新

This commit is contained in:
Zane
2026-05-07 11:14:29 +08:00
parent ff654b91f2
commit 8f3aa6fd3a
12 changed files with 319 additions and 381 deletions

37
setup-task.ps1 Normal file
View File

@@ -0,0 +1,37 @@
#!/usr/bin/env pwsh
# Register the daily 10:30 AM git sync task for this repository.
param(
[string]$TaskName = "Obsidian-Git-Sync-Daily",
[string]$RepoPath = "D:\fork_project\obsidian-notes"
)
$scriptPath = Join-Path $RepoPath "git_sync_daily.ps1"
if (-not (Test-Path $scriptPath)) {
throw "Sync script not found: $scriptPath"
}
$existing = Get-ScheduledTask -TaskName $TaskName -ErrorAction SilentlyContinue
if ($existing) {
Unregister-ScheduledTask -TaskName $TaskName -Confirm:$false
Write-Host "Removed existing task: $TaskName"
}
$action = New-ScheduledTaskAction -Execute "powershell.exe" `
-Argument "-NoProfile -ExecutionPolicy Bypass -WindowStyle Hidden -File `"$scriptPath`" -RepoPath `"$RepoPath`""
$trigger = New-ScheduledTaskTrigger -Daily -At 10:30AM
$settings = New-ScheduledTaskSettingsSet `
-AllowStartIfOnBatteries `
-DontStopIfGoingOnBatteries `
-StartWhenAvailable
Register-ScheduledTask -TaskName $TaskName `
-Action $action `
-Trigger $trigger `
-Settings $settings `
-Description "Daily 10:30 AM git sync for obsidian-notes and InBox/Gantt sync"
Write-Host "Task '$TaskName' registered."
Write-Host "Schedule: daily at 10:30 AM"
Write-Host "Script: $scriptPath"