From ac6264eeb32e8fde39469697d1bd4f72cc356088 Mon Sep 17 00:00:00 2001 From: Codex Agent Date: Tue, 13 Oct 2026 17:35:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8C=81=E7=BB=AD=E5=88=B7=E5=8F=96:=20?= =?UTF-8?q?=E9=97=B4=E9=9A=94=E6=94=B9=202.5=20=E5=B0=8F=E6=97=B6,=20?= =?UTF-8?q?=E5=B9=B6=E4=BF=AE=E6=8E=89=20EveryHours=20=E8=A2=AB=E6=88=AA?= =?UTF-8?q?=E6=96=AD=E7=9A=84=E5=9D=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 3 小时 + 约 2 小时轮次 = 约 33% 时间空转, 压到 2.5 小时可提到约 83%。 过程中踩到两个坑, 都记在脚本注释里: 1. New-TimeSpan -Hours 的参数是 [int], 传 2.5 会被静默截断成 2 小时 —— 结果注册出 PT2H 而不是 PT2H30M, 还误报了一句"间隔短于单轮上限"的警告。 改用 -Minutes ($EveryHours * 60)。$EveryHours 也从 [int] 改成 [double]。 2. ⛔ 又踩了 10-04 坑 6: 编辑 .ps1 会丢掉 BOM, Windows PowerShell 5.1 随即 按 GBK 解析中文注释, 报出一堆行号对不上的语法错。而且我用 pwsh 7 做的 "语法检查"能正确处理 UTF-8, 给了假 OK。 教训: 改完 .ps1 必须补 BOM (EF BB BF), 且必须用 powershell.exe 5.1 实测。 顺带把单轮上限的注释从"每局镜牢约 40 分钟"改成实测值(39~>70 分钟)。 --- scripts/install_unattended.ps1 | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/scripts/install_unattended.ps1 b/scripts/install_unattended.ps1 index 883923b..d99090c 100644 --- a/scripts/install_unattended.ps1 +++ b/scripts/install_unattended.ps1 @@ -5,7 +5,8 @@ # 用法: # powershell -ExecutionPolicy Bypass -File scripts\install_unattended.ps1 # 可选: -At 05:30 每日运行时间。游戏每日重置为 06:00 (KST), 即北京时间 05:00 -# -EveryHours 2 改成"每 N 小时重复一轮"以持续刷取; 0 = 只按 -At 每天一次 +# -EveryHours 2.5 改成"每 N 小时重复一轮"以持续刷取; 0 = 只按 -At 每天一次 +# 单轮上限 = 60 + 75*Mirror 分钟, 间隔要大于它, 否则会被跳过 # -Mirror 1 每轮镜牢局数, 0 = 不打镜牢 # -Target 34 把队内人格升到的等级 # -Python <路径> 默认 vendor\aalc\.venv\Scripts\pythonw.exe (无窗口, 不抢游戏焦点) @@ -16,7 +17,7 @@ # 先手动跑一轮确认无误再装: python scripts\auto_cycle.py --mirror 1 param( [string]$At = "05:30", - [int]$EveryHours = 0, + [double]$EveryHours = 0, [int]$Mirror = 1, [int]$Target = 34, [string]$Python = "", @@ -65,17 +66,18 @@ if (-not $NoWatchdog) { $cycle = Join-Path $PSScriptRoot "auto_cycle.py" $action = New-ScheduledTaskAction -Execute $Python -WorkingDirectory $Repo ` -Argument "-X utf8 `"$cycle`" --mirror $Mirror --target $Target" -# 一轮 daily 约 20 分钟, 每局镜牢约 40 分钟; 超过上限由计划任务强杀 +# 一轮 daily 约 22 分钟, 每局镜牢实测 39~>70 分钟; 超过上限由计划任务强杀 $limit = New-TimeSpan -Minutes (60 + 75 * [Math]::Max($Mirror, 0)) if ($EveryHours -gt 0) { # 持续刷取: 每 N 小时重复一轮。开始时间取"现在", 装完即进入节奏。 + # 注意 New-TimeSpan -Hours 的参数是 [int], 传 2.5 会被截断成 2 小时, 所以用 -Minutes。 $trigger = New-ScheduledTaskTrigger -Once -At (Get-Date).AddMinutes(1) ` - -RepetitionInterval (New-TimeSpan -Hours $EveryHours) ` + -RepetitionInterval (New-TimeSpan -Minutes ($EveryHours * 60)) ` -RepetitionDuration (New-TimeSpan -Days 3650) $desc = "every $EveryHours h" # 重复周期必须大于单轮上限, 否则会在上一轮还没结束时又起一轮 - if ((New-TimeSpan -Hours $EveryHours) -lt $limit) { - Write-Warning "EveryHours=$EveryHours 短于单轮上限 $limit, 可能重叠; MultipleInstances=IgnoreNew 会跳过, 但建议调大" + if (($EveryHours * 60) -lt $limit.TotalMinutes) { + Write-Warning "EveryHours=$EveryHours ($($EveryHours * 60) 分钟) 短于单轮上限 $limit, 可能重叠; MultipleInstances=IgnoreNew 会跳过, 但建议调大" } } else { $trigger = New-ScheduledTaskTrigger -Daily -At $At