Search…
⌃K
Links

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 ReleaseHub, 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

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.