docs: update scheduling instructions in Docker and setup documentation

This commit is contained in:
2025-11-03 19:28:43 +01:00
parent 43ed6cd7f8
commit a932f48425
3 changed files with 2 additions and 98 deletions

View File

@@ -190,102 +190,6 @@ tail -100 /var/log/cron.log
---
**[← Back to Hub](index.md)** | **[Getting Started](getting-started.md)**# 🐳 Docker Guide
**Run the script in a container**
---
## ⚡ Quick Start
### 1. Create Required Files
Ensure you have:
- `src/accounts.jsonc` with your credentials
- `src/config.jsonc` (uses defaults if missing)
### 2. Start Container
## 🎛️ Scheduling Options
### Use a host scheduler (recommended)
- Trigger `docker compose up --build` on your preferred schedule (cron, systemd timers, Task Scheduler, Kubernetes CronJob, etc.).
- Ensure volumes remain consistent so each run reuses accounts, config, and sessions.
- See [External Scheduling](schedule.md) for concrete host examples.
### Enable in-container cron (optional)
1. Set environment variables in `docker-compose.yml` or `docker run`:
build: .
environment:
TZ: "Europe/Paris"
command: ["npm", "run", "start:schedule"]
```
Configure schedule in `src/config.jsonc`:
```jsonc
{
"schedule": {
"enabled": true,
"useAmPm": false,
"time24": "09:00",
"timeZone": "Europe/Paris"
}
}
```
### Option 2: Native Cron (For Traditional Cron Users)
**Pros:**
- ✅ Familiar cron syntax
- ✅ Multiple daily runs with standard crontab
- ✅ Native Linux scheduling
**Setup:**
1. **Enable cron in `docker-compose.yml`:**
```yaml
services:
rewards:
build: .
environment:
TZ: "Europe/Paris"
USE_CRON: "true"
CRON_SCHEDULE: "0 9,16,21 * * *" # 9 AM, 4 PM, 9 PM daily
RUN_ON_START: "true" # Optional: run once on start
```
2. **Cron Schedule Examples:**
| Schedule | Description | Cron Expression |
|----------|-------------|-----------------|
| Daily at 9 AM | Once per day | `0 9 * * *` |
| Twice daily | 9 AM and 9 PM | `0 9,21 * * *` |
| Three times | 9 AM, 4 PM, 9 PM | `0 9,16,21 * * *` |
| Every 6 hours | 4 times daily | `0 */6 * * *` |
| Weekdays only | Mon-Fri at 8 AM | `0 8 * * 1-5` |
**Use [crontab.guru](https://crontab.guru) to validate your cron expressions.**
3. **Rebuild and restart:**
```bash
docker compose down
docker compose build --no-cache
docker compose up -d
```
4. **Verify cron is running:**
```bash
# Check container logs
docker logs -f microsoft-rewards-bot
# Should see: "==> Cron mode enabled"
# View cron logs inside container
docker exec microsoft-rewards-bot tail -f /var/log/cron.log
```
### Option 3: Single Run (Manual)
```yaml

Binary file not shown.