pyawscron is a Python library that parses and interprets AWS EventBridge (formerly CloudWatch Events) cron expressions. It supports all AWS-specific cron syntax, including special wildcards like 'L', 'W', and '#', and can calculate next, previous, or all occurrences within a date range. The current version is 1.0.7, with releases addressing compatibility and parsing nuances.
pip install pyawscronVerified import paths — ran on the pinned version, not inferred.
Initializes an AWSCron object with an AWS-specific cron expression and demonstrates how to retrieve the next `n` schedule occurrences. It highlights the use of `datetime` objects with timezone information.
Always consult AWS EventBridge/CloudWatch cron documentation. This library is designed specifically for AWS syntax.
Ensure that if Day-of-month or Day-of-week has a specific value or '*', the other field uses '?' to indicate 'no specific value'.
Upgrade to 1.0.6 or newer for correct 'W' wildcard behavior. Understand its specific meaning beyond a simple 'weekday'.
For potentially numerous occurrences, prefer `get_next_n_schedule` for an iterative approach or process smaller date ranges.
Upgrade to `pyawscron` version 1.0.7 or newer to benefit from relaxed `python-dateutil` dependency constraints.
You need to install the library using pip: `pip install pyawscron`
Ensure your AWS cron expression has the correct number of fields (e.g., 'minutes hours day-of-month month day-of-week year' or 'minutes hours day-of-month month day-of-week'). Refer to AWS documentation for the exact format, e.g., `cron(0 12 * * ? *)` for a 6-field expression.
Modify your cron expression to use '?' in either the Day-of-month or Day-of-week field if the other field contains a specific value or '*'. For example, `cron(0 10 ? * MON *)` for every Monday at 10:00 UTC.
Carefully review your cron expression for typos, missing quotes, or incorrect characters. Also, check the Python code where `pyawscron.AWSCron()` is called to ensure correct Python syntax (e.g., proper parentheses, string formatting).