> ## Documentation Index
> Fetch the complete documentation index at: https://levers9.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Cron

> Demo: cron

Source: `demo/cron/app.py` in the repository.

A function that runs itself on a cron expression. Time is always UTC.

```bash theme={null}
cd demo/cron

# run the function once, right now (no cron involved)
python app.py

# deploy the cron: fires every two minutes and appends to demo-data/cron.log
levers9 deploy app.py:report --name every-2-minutes

# watch it fire
levers9 task list
levers9 ls demo-data
levers9 cp demo-data/cron.log ./cron.log && cat cron.log

# stop it
levers9 deployment list
levers9 deployment stop `deployment id`
```

Notes

* `when=` takes a standard five-field cron expression, or a named one: `@hourly`, `@daily`, `@weekly`,
  `@monthly`, `@yearly`.
* A cron is a deployment: stopping the deployment stops the cron; deploying again makes a new
  version and the old one is retired.
* Use a volume (as here) or a return value stored elsewhere to keep results; a scheduled container is
  thrown away after each run.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.