# Linux Setup Guide

## Quick Start

### 1️⃣ Make scripts executable
```bash
chmod +x run.sh install-cron.sh uninstall-cron.sh
```

### 2️⃣ Run scraper manually
```bash
./run.sh
```

Generates `calendar.ics` with 270 events.

### 3️⃣ Install weekly auto-run (optional)
```bash
./install-cron.sh
```

Prompts you to choose:
- Day of week (0-6 = Sun-Sat)
- Time (hour and minute)

Then adds to your crontab automatically.

---

## Files

| File | Purpose |
|------|---------|
| `run.sh` | Run scraper once |
| `install-cron.sh` | Install weekly cron job |
| `uninstall-cron.sh` | Remove cron job |

---

## Examples

### Run now
```bash
./run.sh
```

### Schedule for Monday 8 AM
```bash
./install-cron.sh
# Choose: day=1, hour=8, minute=0
```

### Schedule for Friday 6 PM
```bash
./install-cron.sh
# Choose: day=5, hour=18, minute=0
```

### View installed cron job
```bash
crontab -l
```

### Remove cron job
```bash
./uninstall-cron.sh
```

---

## Logs

Cron job output saved to: `cron.log`

View last runs:
```bash
tail cron.log
```

---

## Manual Cron Setup (if needed)

Edit crontab:
```bash
crontab -e
```

Add line (example: every Monday at 8 AM):
```bash
0 8 * * 1 cd /path/to/script && ./run.sh >> cron.log 2>&1
```

---

## Troubleshooting

**Cron job not running?**
```bash
# Check crontab
crontab -l

# View system logs
tail -f /var/log/syslog | grep CRON

# Check if user can run crontab
crontab -l
```

**Permission denied?**
```bash
chmod +x run.sh install-cron.sh uninstall-cron.sh
```

**Python not found?**
```bash
# Check if python3 or python exists
which python3
which python

# Run with full path if needed
/usr/bin/python3 agenda_simple.py
```

---

## Notes

- Scripts are designed for Ubuntu/Debian/Fedora
- Requires: Python 3.7+, pip, bash
- Cron job runs with your user permissions
- Output logged to `cron.log`

---

That's it! Just run and schedule. 🎉
