Search…
Cron Jobs
How to create cron jobs

Understanding CronJobs

CronJobs let you run scripts and other jobs periodically, either based on an interval (e.g. every 10 minutes), or on a schedule (e.g. every Tuesday at 3:00 AM).

Creating a CronJob in your environment

To create CronJobs 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.
1
# ...
2
cron_jobs:
3
- name: hello-cron
4
schedule: "0/5 * * * *"
5
image: busybox
6
command:
7
- sh
8
- "-c"
9
- "echo 'hi from cron'"
Copied!
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

The difference between CronJobs and jobs

CronJobs are distinct from jobs in that:
  • CronJobs are run on a schedule or timer
  • Jobs are run manually or based on events, e.g. after a backend service comes up.

The CronJobs Schema

Instead of choosing an image to base your CronJob on, you can instead define from_services to base your CronJob on an existing service. You can find more examples and the full schema in the Schema docs.