# Cron and Watch

> Have zelk post a prompt into the conversation on a schedule, or wake it when a command prints a line or a page changes.

Most work starts with your message. Two tools let the agent start work for
itself, in the same conversation:

- **Cron** posts a prompt into the conversation at the times a cron
  expression names: "check the deploy every morning at 9:07".
- **Watch** runs a command in the background and wakes the conversation
  with each line it prints: a log to follow, a CI status to poll, a file
  watcher.

Both work as Claude Code's cron tools and Monitor do. They live while zelk
has the conversation open, and what they bring arrives as a notice in that
conversation. Nothing runs while zelk is closed.

## Cron

The Cron tools come with `-scheduling`, or `"scheduling": true` in
`~/.config/zelk/config.json`:

```sh
zelk -scheduling
```

Then ask for what you want in your own words, such as "every weekday at
9am, check whether the nightly build passed". The agent uses three tools:

| Tool | Does |
|---|---|
| `CronCreate` | schedules a prompt at the times a five-field cron expression names, recurring or once |
| `CronList` | lists the conversation's pending crons, with each one's next time |
| `CronDelete` | stops one; a prompt it already posted stays |

`CronCreate` answers with the cron's next three times, in local time and
UTC, so you can see it understood you. Expressions have five fields
(minute, hour, day of month, month, day of week) with numbers, ranges,
lists and steps, in your local time zone.

How crons behave:

- **Times are exact.** 9:00 fires at 9:00; the agent picks an off minute
  when your time was approximate.
- **Missed times fire once.** Times that passed while zelk was closed, or
  while the conversation was busy, arrive as one prompt when the
  conversation is next open and idle. When more than one time came due,
  the prompt says how many.
- **No overlap.** A time that falls due while the last prompt's run is
  still going is counted into the next one.
- **No expiry.** A recurring cron lasts until it is deleted. A session with
  a live cron isn't removed by the 30-day cleanup.
- **No approval to create.** A cron only posts a prompt into its own
  conversation; what that prompt leads to is decided as it happens. Plan
  mode refuses the Cron tools, and rules naming them hold.

Crons fire only while a host holds the conversation open: the terminal UI
checks every five seconds, and `zelk acp` on its own tick. `zelk -p` and
`zelk exec` end with their run, so a cron they create never fires.

## Watch

`Watch` is offered wherever Bash is; there is nothing to turn on. Ask, for
example, "watch the CI run and tell me when it finishes". The agent runs a
command such as `gh run watch` or a `tail -f` through `grep`, and each line
it prints wakes the conversation:

- An idle conversation starts a run with the lines.
- A run under way takes them in, often because it is waiting for exactly
  that line.

Lines that arrive close together come as one notice. At most one notice
comes per `min_interval` (10 seconds by default), and more than 60 in an
hour stops the watch, telling the agent to narrow its filter. A watch ends
when its command exits, when `stop_after` passes, when it is stopped, or
when zelk closes. The command is decided as a Bash command when the watch
starts, and runs as one, in the sandbox when there is one.

Watches are background processes: the terminal UI lists them in
**Background work…**, where you can read their output and stop them.
Within one `zelk -p` or `zelk exec` run a watch works too, and ends with
the run.

A watch never restarts by itself. When you reopen a conversation whose
watch ended with zelk, the agent is told so and decides whether to start
it again. When a conversation is deleted and recreated, any late notices
from its old watches stay out of the new conversation.

## Watching a page

With [your own browser](/cli/browser/#your-own-browser), the agent can
watch a page for changes: a price, a queue, a status. `user_browser_watch`
installs a script in a trusted tab that wakes the conversation with a value
whenever it changes, at most once per minute by default. It survives the
page reloading, and lasts until the session ends, the agent unwatches it or
the tab closes; the extension's Stop pauses it.

A page watch needs a session that stays open to be woken, the terminal UI
or `zelk acp`: `zelk -p` and `zelk exec` refuse one. When a watch was not
running for a while (zelk closed, your Stop, a lost link), its next wake
says so, so the agent doesn't mistake a jump for a change it saw.

## Where to go deeper

- [The wakes contract](/internals/wakes/): sources, the inbox, admission,
  and the exact Cron and Watch rules
- [Built-in tools](/reference/tools/) and [settings](/reference/settings/)
