# Windows Task Scheduler — daily 03:00 maintenance # # Runs consolidate, then drain-shutdown-queue in one invocation. # # Prerequisites: # 1. pnpm build # 2. Edit templates/consolidate.cmd.example (__NODE__, __CLI__) # 3. `logs/` is created by Pi session start or `pi-memory init`; consolidate.cmd also mkdirs before redirect. # # Option A — schtasks with wrapper script (recommended): # # schtasks /Create ^ # /TN "PiMemoryMaintenance" ^ # /TR "C:\path\to\pi-memory\templates\consolidate.cmd" ^ # /SC DAILY /ST 03:00 /F # # Option B — schtasks inline (replace paths): # # schtasks /Create ^ # /TN "PiMemoryMaintenance" ^ # /TR "\"C:\Program Files\nodejs\node.exe\" \"C:\path\to\pi-memory\dist\cli.js\" maintenance --cron --verbose" ^ # /SC DAILY /ST 03:00 /F # # Set env vars for the task (Task Scheduler → Properties → Environment): # PI_MEMORY_ENV_FILE = %USERPROFILE%\.pi\agent\pi-memory.env # PI_MEMORY_AGENT_DIR = %USERPROFILE%\.pi\pi-memory-data # # Manual test: # schtasks /Run /TN "PiMemoryMaintenance" # # Remove: # schtasks /Delete /TN "PiMemoryMaintenance" /F # # Logs: %USERPROFILE%\.pi\pi-memory-data\logs\maintenance.log