Commands
Cron
Documentation for the /cron command to work with cron expressions
/cron
Command
The /cron
command provides tools to work with cron expressions. Cron is a time-based job scheduler used in Unix-like operating systems, and cron expressions are used to define when automated tasks should run.
Available Subcommands
Explain a Cron Expression
Explains a cron expression in human-readable form.
Options
Option | Description | Required |
---|---|---|
expression | The cron expression to explain (e.g., ‘0 0 * * *‘) | Yes |
Example
Output
Calculate Next Executions
Calculates the next executions of a cron expression.
Options
Option | Description | Required |
---|---|---|
expression | The cron expression (e.g., ‘0 0 * * *‘) | Yes |
count | Number of executions to show (default: 5, max: 10) | No |
Example
Output
Generate a Cron Expression
Generates a cron expression from individual fields.
Options
Option | Description | Required |
---|---|---|
minute | Minute field (0-59, *, */5, etc.) | No |
hour | Hour field (0-23, *, */2, etc.) | No |
day | Day of month field (1-31, *, etc.) | No |
month | Month field (1-12, *, etc.) | No |
weekday | Day of week field (0-6, *, etc., where 0=Sunday) | No |
Example
Output
Show Common Cron Expressions
Shows common cron expressions or details about a specific common expression.
Options
Option | Description | Required |
---|---|---|
name | Name of the common expression | No |
Example 1 (list all common expressions)
Output 1
Example 2 (specific common expression)
Output 2
Understanding Cron Expressions
Cron expressions consist of five fields separated by spaces:
Common Patterns
Pattern | Description | Example |
---|---|---|
* | Any value | * * * * * = run every minute |
, | Value list separator | 1,15 * * * * = run at minute 1 and 15 |
- | Range of values | 1-5 * * * * = run every minute from 1 through 5 |
/ | Step values | */15 * * * * = run every 15 minutes |
0-59 | Allowed values for minutes | 0 * * * * = run at minute 0 (top of every hour) |
0-23 | Allowed values for hours | 0 0 * * * = run at midnight (00:00) |
1-31 | Allowed values for days of the month | 0 0 1 * * = run at midnight on the 1st of every month |
1-12 | Allowed values for months | 0 0 * 1 * = run at midnight every day in January |
0-6 | Allowed values for days of the week (0=Sunday) | 0 0 * * 0 = run at midnight on Sundays |
Platform-Specific Implementation Notes
Use Cases
- Schedule recurring tasks in systems and applications
- Configure automated backups
- Set up periodic data processing jobs
- Automate system maintenance tasks
- Plan recurring notifications or reports
- Schedule regular builds or deploys in CI/CD pipelines
Notes
- All cron expressions use UTC time zone
- The standard cron format with 5 fields is supported (minute, hour, day, month, weekday)
- Special characters like
@yearly
,@monthly
, etc. are not supported - The maximum number of next executions that can be displayed is 10
Was this page helpful?