> For the complete documentation index, see [llms.txt](https://docs.release.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.release.com/guides-and-examples/running-instances/cron-jobs.md).

# Cron jobs

How to create cron jobs

## Understanding cron jobs

Cron jobs let you run scripts and other jobs periodically, either based on an interval (for example, every ten minutes) or on a schedule (for example, every Tuesday at 03:00 AM).

## Creating a cron job in your environment

To create cron jobs in Release, edit your "Environment Configuration" under **Settings**.

![Edit environment configuration](https://585411240-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M1neGLLQ0sDXeK6ooSo%2Fuploads%2Fgit-blob-3b9aec97240fdd6463e468e92b1e8930c69ffd9f%2Fjobs-edit-evironment-configuration.png?alt=media)

1. At the end of the YAML, add a section called `cron_jobs` and define any jobs you want to run following the example below.

```yaml
# ...
cron_jobs:
  - name: hello-cron
    schedule: "0/5 * * * *"
    image: busybox
    command:
      - sh
      - "-c"
      - "echo 'hi from cron'"
```

2. Press **Save as new version**.

![Save new configuration version](https://585411240-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M1neGLLQ0sDXeK6ooSo%2Fuploads%2Fgit-blob-00b626d305ab82f2ad4d2db2edd699374746bffa%2Fcronjobs-cron-configuration-block.png?alt=media)

3. Click **Deploy** -> **Deploy Patch** to apply this new configuration to your environment. This will redeploy your existing instances, and also add a new one to run the cron job you defined.

![Apply latest configuration](https://585411240-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M1neGLLQ0sDXeK6ooSo%2Fuploads%2Fgit-blob-5fc1384287683ba6e467d6c58dad2cd8a438344d%2Fjobs-apply-latest-config.png?alt=media)

Wait for the new environment to deploy. If you used the configuration from the example above, you should see a new instance come up every five minutes. Viewing the logs of that instance will confirm that the job ran as expected.

![Viewing the CronJob log](https://585411240-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M1neGLLQ0sDXeK6ooSo%2Fuploads%2Fgit-blob-d2b5562a50d074582463516ccc6bf0c94a0a9a2f%2Fcronjobs-cron-log-success.png?alt=media)

## The difference between cron jobs and jobs

Cron jobs are distinct from jobs in that:

* Cron jobs are run on a schedule or timer.
* Jobs are run manually or based on events, for example, after a backend service comes up.

## The cron jobs schema

Instead of choosing an `image` to base your cron job on, you can define `from_services` to base your cron job on an existing service. You can find more examples and the full schema in the [schema docs](/reference-documentation/application-settings/application-template/schema-definition.md#cron-jobs).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.release.com/guides-and-examples/running-instances/cron-jobs.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
