'How to use 0/10 in cron in a yaml file?
I'm trying to use a cron job referenced in a yaml file part as part of my CircleCI CI system:
I would like a job to run every 10 mins using the 0/10 * * * *
format but I get:
Config does not conform to schema
So how to use 0/10
in cron in a yaml file?`
Using a valid cron expression:
https://crontab.guru/#0/10_*_*_*_*
I get
Config does not conform to schema:
{:workflows {:hourly {:triggers [{:schedule {:cron (not (:circleci.specs.cron/posix-expr \"0/10 * * * *\"))}}]}}}
I tried various format such as
cron: "0/10 * * * *"
cron: 0/10 * * * *
cron: "0\/10 * * * *"
cron: 0\/10 * * * *
but none were valid for allowing the slash.
Rest of section for context:
hourly:
triggers:
- schedule:
cron: "0/10 * * * *"
filters:
branches:
only:
- master
- circleci-project-setup:
Solution 1:[1]
The docs say
cron key is defined using POSIX crontab syntax.
The linked manpage does not specify /
. It is non-standard and apparently not supported. Wikipedia says that
POSIX does not define a use for slashes; its rationale (commenting on a BSD extension) notes that the definition is based on System V format but does not exclude the possibility of extensions
So you just can't use /
here.
You can use the equivalent
"0,10,20,30,40,50 * * * *"
Solution 2:[2]
You can use >
operator
So this example works for cron expression:
schedule: >
'*/3 * * * *'
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | flyx |
Solution 2 |