# External Scheduling The built-in scheduler has been removed. Use your operating system or orchestrator to trigger runs with full control over timing, retries, and monitoring. --- ## Windows Task Scheduler 1. Open Task Scheduler, choose **Create Basic Task...**, and name it `Microsoft Rewards Bot`. 2. Pick a trigger (daily, weekly, at startup, etc.). 3. Choose **Start a Program** and configure: - Program/script: `powershell.exe` - Arguments: `-NoProfile -ExecutionPolicy Bypass -Command "cd 'C:\Users\YourUser\Microsoft-Rewards-Script'; npm run start"` - Start in (optional): `C:\Users\YourUser\Microsoft-Rewards-Script` 4. Finish the wizard, edit the task → **General** tab, and enable **Run whether user is logged on or not**. Grant highest privileges if required. 5. Test with **Run**. Append `| Tee-Object -FilePath C:\Logs\rewards.log` to capture output in a file. > Tip: prefer a batch file? Create `run-rewards.bat` with `cd /d C:\Users\YourUser\Microsoft-Rewards-Script` and `npm run start`, then point Task Scheduler to that file. --- ## Linux / macOS (cron) 1. Run `npm run start` once to confirm the project completes successfully. 2. Edit the crontab: `crontab -e`. 3. Add an entry (example: 09:15 daily): ```cron 15 9 * * * cd /home/you/Microsoft-Rewards-Script && /usr/bin/env npm run start >> /home/you/rewards.log 2>&1 ``` 4. Save the file and verify the log after the next trigger. Need multiple runs? Add more cron lines with different times (for example `0 9 * * *` and `30 18 * * *`). --- ## Systemd Timer (Linux alternative) 1. Create `/etc/systemd/system/rewards-bot.service`: ```ini [Unit] Description=Microsoft Rewards Bot WorkingDirectory=/home/you/Microsoft-Rewards-Script [Service] Type=oneshot Environment=NODE_ENV=production ExecStart=/usr/bin/env npm run start ``` 2. Create `/etc/systemd/system/rewards-bot.timer`: ```ini [Unit] Description=Run Microsoft Rewards Bot daily [Timer] OnCalendar=*-*-* 09:00:00 Persistent=true [Install] WantedBy=timers.target ``` 3. Reload and enable: ```bash sudo systemctl daemon-reload sudo systemctl enable --now rewards-bot.timer ``` 4. Inspect status via `systemctl status rewards-bot.timer` and recent runs with `journalctl -u rewards-bot.service`. --- ## Docker & Containers - The container now runs a single pass. Restart it on your schedule (cron, Kubernetes CronJob, Task Scheduler, etc.). - To schedule inside the container, set: ```yaml USE_CRON: "true" CRON_SCHEDULE: "0 9 * * *" RUN_ON_START: "true" ``` The entrypoint installs cron, runs according to `CRON_SCHEDULE`, and tails `/var/log/cron.log`. - Mount `accounts.jsonc`, `config.jsonc`, and `sessions/` so each run shares state. --- ## Troubleshooting - Run `npm install` and `npm run build` after pulling updates. - Use absolute paths in scheduler commands. - Redirect output to a log file for easier debugging. - Execute `npm run start` manually after configuration changes to trigger the startup validator. --- **Next steps:** [Configuration](./config.md) · [Docker](./docker.md) · [Humanization](./humanization.md)# ? External Scheduling The built-in scheduler has been removed. Use your operating system or orchestrator to trigger runs with full control over timing, retries, and monitoring. --- ## Windows Task Scheduler 1. Open **Task Scheduler** ? **Create Basic Task�** and name it Microsoft Rewards Bot. 2. Choose a trigger (daily, weekly, or at startup). 3. Select **Start a Program** and configure: - **Program/script:** powershell.exe - **Add arguments:** -NoProfile -ExecutionPolicy Bypass -Command "cd 'C:\Users\YourUser\Microsoft-Rewards-Script'; npm run start" - **Start in (optional):** C:\Users\YourUser\Microsoft-Rewards-Script 4. Finish the wizard, then edit the task ? **General** tab: - Enable **Run whether user is logged on or not** for background execution. - Check **Run with highest privileges** if required. 5. Test with **Run**. Redirect output to a log file by appending | Tee-Object -FilePath C:\Logs\rewards.log to the PowerShell command. > Prefer a batch file? Create un-rewards.bat with cd /d C:\Users\YourUser\Microsoft-Rewards-Script and pm run start, then point the task to that file. --- ## Linux / macOS (cron) 1. Verify a manual run succeeds: pm run start from the project directory. 2. Edit the crontab: crontab -e. 3. Add an entry (example: 09:15 every day): `cron 15 9 * * * cd /home/you/Microsoft-Rewards-Script && /usr/bin/env npm run start >> /home/you/rewards.log 2>&1 ` 4. Save and exit. Confirm execution after the first trigger by inspecting the log file. Need multiple passes? Add additional cron lines with different times (e.g., 9 * * * and 30 18 * * *). --- ## Systemd Timer (Linux alternative) 1. Create /etc/systemd/system/rewards-bot.service: `ini [Unit] Description=Microsoft Rewards Bot WorkingDirectory=/home/you/Microsoft-Rewards-Script [Service] Type=oneshot Environment=NODE_ENV=production ExecStart=/usr/bin/env npm run start ` 2. Create /etc/systemd/system/rewards-bot.timer: `ini [Unit] Description=Run Microsoft Rewards Bot daily [Timer] OnCalendar=*-*-* 09:00:00 Persistent=true [Install] WantedBy=timers.target ` 3. Enable the timer: `ash sudo systemctl daemon-reload sudo systemctl enable --now rewards-bot.timer ` 4. Check status with systemctl status rewards-bot.timer and recent runs via journalctl -u rewards-bot.service. --- ## Docker & Containers - The container now performs a single pass by default. Restart it on your schedule (host cron, Kubernetes CronJob, etc.). - To keep scheduling inside the container, set environment variables: `yaml USE_CRON: "true" CRON_SCHEDULE: "0 9 * * *" # Daily at 09:00 RUN_ON_START: "true" # Optional immediate run when the container boots ` The entrypoint installs cron, runs the command according to CRON_SCHEDULE, and tails /var/log/cron.log. - Persist ccounts.jsonc, config.jsonc, and sessions/ with volumes so each run shares state. --- ## Troubleshooting - Ensure dependencies are installed ( pm install) and the project is built ( pm run build) after updates. - Use absolute paths in scheduler commands to avoid working-directory issues. - Redirect stdout/stderr to log files for easier debugging. - Rerun the **Startup Validator** by executing pm run start once after configuration changes. --- **Next steps:** [Configuration](./config.md) � [Docker](./docker.md) � [Humanization](./humanization.md)