Detailed explanation and examples for this cron schedule pattern
0 */21 * * *
0 0 */21 * * ?
0 0 */21 * * ? *
0 */21 * * *
0 */21 * * * /path/to/command
cron: '0 */21 * * *'
cron(0 \*/21 \* \* \*)
0 */21 * * *
"schedule": "0 */21 * * *"
cron: '0 */21 * * *'
schedule: "0 */21 * * *"
placement: { constraints: [node.role == manager] }
labels: { cron: "0 */21 * * *" }
CronScheduleBuilder.cronSchedule("0 */21 * * *")
cron.schedule('0 */21 * * *', function() {
// Your code here
});
from crontab import CronTab
cron = CronTab(user='username')
job = cron.new(command='/path/to/command')
job.setall('0 */21 * * *')
# config/packages/messenger.yaml
framework:
messenger:
transports:
cron: '%env(MESSENGER_TRANSPORT_DSN)%'
options:
cron_expression: '0 */21 * * *'
This cron expression is composed of 5 time/date fields:
Field | Value | Description |
---|---|---|
Minute | 0 | 0 |
Hour | */21 | Every 21 hours (0-23) |
Day of Month | * | Every day of the month (1-31) |
Month | * | Every month (1-12) |
Day of Week | * | Every day of the week (0-6, where 0 is Sunday) |
In Quartz, we add a seconds field (and can replace * with ? in day-of-week):
Field | Value | Description |
---|---|---|
Second | 0 | 0 |
Minute | 0 | 0 |
Hour | */21 | Every 21 hours (0-23) |
Day of Month | * | Every day of the month (1-31) |
Month | * | Every month (1-12) |
Day of Week | ? | Any value (no specific value) |
AWS CloudWatch Events adds an optional year field:
Field | Value | Description |
---|---|---|
Minute | 0 | 0 |
Hour | */21 | Every 21 hours (0-23) |
Day of Month | * | Every day of the month (1-31) |
Month | * | Every month (1-12) |
Day of Week | * | Every day of the week (0-6, where 0 is Sunday) |
Year (Optional) | * | Every year |
Note that different systems interpret cron expressions slightly differently. The standard Unix format has 5 fields, while Quartz and AWS formats have additional fields. Some special characters like ?, L, W, and # are only supported in specific implementations.
This job runs every 21 hours
0 * * * *
0 */2 * * *
0 */3 * * *
0 */4 * * *
0 */6 * * *
0 */8 * * *
0 */12 * * *
0 */5 * * *
0 */7 * * *
0 */9 * * *
0 */10 * * *
0 */11 * * *
0 */13 * * *
0 */14 * * *
0 */15 * * *
0 */16 * * *
0 */17 * * *
0 */18 * * *
0 */19 * * *
0 */20 * * *
0 */22 * * *
0 */23 * * *