1# Outlook Sync - Automated Scheduling
2
3## ✅ CORRECT Cron Setup
4
5```bash
6# Every hour at :00 (recommended)
70 * * * * cd /var/www/html/dokuwiki/lib/plugins/calendar && php sync_outlook.php >> sync.log 2>&1
8
9# Every 30 minutes (more frequent)
10*/30 * * * * cd /var/www/html/dokuwiki/lib/plugins/calendar && php sync_outlook.php >> sync.log 2>&1
11
12# Every 15 minutes (very frequent)
13*/15 * * * * cd /var/www/html/dokuwiki/lib/plugins/calendar && php sync_outlook.php >> sync.log 2>&1
14```
15
16## ❌ WRONG - DO NOT USE --reset
17
18```bash
19# ❌ NEVER DO THIS - Will search Outlook every time and could create duplicates
200 * * * * cd /path && php sync_outlook.php --reset >> sync.log 2>&1
21```
22
23## Why No --reset?
24
25**--reset** clears the mapping file and forces the script to search Outlook for every event.
26
27- ✅ **Normal sync**: Uses mapping file → knows what's already synced → fast & reliable
28- ❌ **--reset every hour**: Searches Outlook → slow → unnecessary → risky
29
30## When to Use --reset
31
32**Only use `--reset` for:**
331. Initial setup (first time)
342. After major Outlook cleanup
353. If sync_state.json gets corrupted
364. Troubleshooting duplicates
37
38**How often:** Once, maybe twice ever. NOT in cron!
39
40## Monitoring Your Sync
41
42### Check Last Run
43```bash
44tail -20 sync.log
45```
46
47### Check for Errors
48```bash
49grep ERROR sync.log | tail -10
50```
51
52### Check Stats
53```bash
54tail sync.log | grep "Sync Complete" -A10
55```
56
57**Expected Output (hourly):**
58```
59Scanned: 321 events
60Created: 0      ← Should be 0 after initial sync
61Updated: 5      ← Only changed events
62Recreated: 0
63Deleted: 0
64Skipped: 205    ← Recurring event occurrences
65Errors: 0
66```
67
68## Log Rotation
69
70Your sync.log will grow. Rotate it monthly:
71
72```bash
73# Add to cron
740 0 1 * * mv /path/sync.log /path/sync.log.$(date +\%Y\%m) && touch /path/sync.log
75```
76
77## Version 3.3
78