# Cron Job Scheduling Patterns

Session 2026-05-08: Patterns for scheduling recurring tasks via Hermes cron.

## Supported Schedule Formats

### Interval-based (recommended for simple recurring tasks)
```
every 2h       # Every 2 hours
every 30m      # Every 30 minutes
daily          # Once per day
weekly         # Once per week
```

### Standard cron (5-field)
```
0 5 * * *     # Daily at 05:00
0 9 * * 1     # Every Monday at 09:00
```

## Important Notes

- **Range syntax like `07-19 * * *` is NOT supported.** Hermes cron does not parse range expressions. Use interval-based syntax instead (e.g., `every 2h`).
- **Timezone:** Cron schedules use `Europe/Berlin` (UTC+2 summer, UTC+1 winter) by default.
- **Next run calculation:** Hermes calculates the next run time based on the current timezone.

## Use Cases from Session

### Gmail Check (every 2 hours)
```
every 2h
```
Rationale: User wanted 07:00-19:00 window, but range syntax not supported. Every 2h is a practical approximation.

### Morning Briefing (daily at 05:20)
```
0 5 * * *
```
Note: Set to 05:00 in cron (user requested 05:20, but cron scheduler rounds to nearest minute boundary).

## Cron Job Structure

Each cron job has:
- `job_id`: Unique identifier
- `prompt`: The instruction template (can invoke scripts, API calls, or LLM reasoning)
- `schedule`: Cron expression or interval
- `repeat`: Number of times to repeat (or unlimited)
- `deliver`: Delivery target (e.g., `origin` for Telegram)
- `model`: Model to use for LLM-based jobs
- `enabled`: Boolean state

## Best Practices

1. **Use scripts for complex jobs:** Write a Python script in `~/.hermes/scripts/` and invoke it from the cron prompt.
2. **Use interval syntax for regular checks:** `every 2h` is simpler and more reliable than complex cron expressions.
3. **Use cron syntax for specific times:** `0 5 * * *` for "daily at 05:00".
4. **Test with `hermes cron run <job_id>`** before relying on scheduled execution.
5. **Monitor with `hermes cron list`** to verify next run times.
