Skip to main content

☑️ Ensure CronJob scheduler is valid

You should always confirm that the cron schedule expression is valid or your jobs won't be executed.

Targeted objects by this rule (types of kind): CronJob

Complexity: easy (What does this mean?)

Policy as code identifier: CRONJOB_INVALID_SCHEDULE_VALUE


This rule will fail​

If the schedule value is not a valid cron expression

kind: CronJob
spec:
schedule: "1 * * *"

Rule output in the CLI​

$ datree test *.yaml

>> File: failExample.yaml
❌ Ensure CronJob scheduler is valid [1 occurrence]
💡 Incorrect value for key `schedule` - the (cron) schedule expressions is not valid and, therefore, will not work as expected

How to fix this failure​

Specify a valid cron expression

kind: CronJob
spec:
schedule: "*/1 * * * *"

Read more​