Comment on page
Cron jobs
How to create 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).
To create cron jobs in Release, edit your "Environment Configuration" under Settings.

Edit environment configuration
At the end of the YAML, add a section called
cron_jobs
and define any jobs you want to run following the example below.# ...
cron_jobs:
- name: hello-cron
schedule: "0/5 * * * *"
image: busybox
command:
- sh
- "-c"
- "echo 'hi from cron'"
Press Save as new version.

Save new configuration version
Back in your Environment Settings page, 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
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
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.
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.Last modified 11mo ago