elasticsearch-croneval
Evaluate Elasticsearch cron expressions
TLDR
Evaluate a cron expression and display the next 10 trigger times (default behavior)
Evaluate a cron expression and display a specific number of future trigger times
Display detailed information (including stack trace) for an invalid cron expression
Display minimal output (silent mode)
Display verbose output
SYNOPSIS
elasticsearch-croneval [options...] <cron_expression>
PARAMETERS
-h, --help
Display help message and exit
--start <date>
Start date for evaluation (ISO-8601 format, e.g., 2023-01-01T00:00:00); defaults to now
--end <date>
End date for evaluation (ISO-8601); defaults to start + 1 year
--count <integer>
Maximum number of execution times to list; defaults to 10
--format <format>
Output format string (e.g., yyyy-MM-dd HH:mm:ss); defaults to ISO
DESCRIPTION
The elasticsearch-croneval command is a utility tool bundled with Elasticsearch distributions, designed to parse and evaluate cron expressions used in scheduling tasks, such as Kibana watcher actions or index lifecycle policies.
It simulates cron job executions by computing and listing the exact timestamps when a given cron expression would trigger, within a specified date range. This is invaluable for developers and operators debugging or validating complex cron schedules without waiting for real-time executions.
Powered by Elasticsearch's internal cron parser (inspired by Quartz Scheduler), it handles standard cron formats: five fields (minute, hour, day-of-month, month, day-of-week) with support for wildcards (*), lists (1,2,3), ranges (1-5), steps (/2), and names (MON-FRI).
Usage involves invoking the tool from the Elasticsearch bin directory, providing a cron string and optional date bounds. Output defaults to human-readable ISO dates but can be customized. It requires a Java runtime matching Elasticsearch's version and accesses the Elasticsearch classpath for proper parsing.
This tool aids in ensuring schedules align with expectations, preventing misconfigurations in production environments.
CAVEATS
Requires Elasticsearch installation and matching Java version. Cron expressions must follow Elasticsearch/Quartz syntax, not traditional Unix cron (e.g., supports seconds field optionally). Output may be voluminous for frequent schedules; use --count to limit.
EXAMPLES
elasticsearch-croneval '0 0 * * *'
Lists daily midnight triggers.
elasticsearch-croneval --start 2024-01-01 --end 2024-02-01 '0 9-17 * * 1-5'
Weekday business hours in January.
LOCATION
Found in $ES_HOME/bin/elasticsearch-croneval; run with ./elasticsearch-croneval from install dir.
HISTORY
Introduced in Elasticsearch 6.0 (2017) as part of watcher enhancements; evolved with Quartz cron parser updates in later versions like 7.x and 8.x for better scheduling in ILM and SLM features.


