Cron jobs
In order to execute the tasks in a Kubernetes CronJob, the scheduling have to be converted to cron format. Some examples can be found in the table below. For more information visit crontab guru.
| Schedule | cron schedule expression | |
|---|---|---|
| Every 10 minutes | */10 * * * * | edit |
| Every hour at… :00 | 0 * * * * | edit |
| Every hour at… :20 | 20 * * * * | edit |
| Every day at… 12:00 AM | 0 12 * * * | edit |
| Every day at… 4:30 AM | 30 4 * * * | edit |
To define a cronjob you need to define a cronJobs in your gap.yaml every element in the cronJobs list is going to be a cronjob. More on gap.yaml here.
name: <your-app-name>
namespace: <your-teams-namespace>
cronJobs:
<your-cronjob-name>:
schedule: <your-cron-expression>
command:
- <your-command-to-run>
activeDeadlineSeconds: 60
You can change CronJob configs per environment:
Suspend a job.
gap/production/gap.yaml
name: my-app
namespace: my-namespace
cronJobs:
my-cronjob:
suspend: true
Change schedule in staging environment.
gap/staging/gap.yaml
name: my-app
namespace: my-namespace
cronJobs:
my-cronjob:
schedule: 0 10 0 * *
To provide a time zone for the schedule to be interpreted in, the cronJobs.<your-cronjob-name>.timeZone field can be used.
name: <your-app-name>
namespace: <your-teams-namespace>
cronJobs:
<your-cronjob-name>:
schedule: <your-cron-expression>
# provide a valid tz-identifier for the timeZone field. Example: "Asia/Baku"
timeZone: <tz-identifier>
See this document for valid time zone identifiers.