{"id":5389,"library":"pyawscron","title":"AWS Cron Parser","description":"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.","status":"active","version":"1.0.7","language":"en","source_language":"en","source_url":"https://github.com/pitchblack408/pyawscron","tags":["aws","cron","parser","scheduling","eventbridge","cloudwatch"],"install":[{"cmd":"pip install pyawscron","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Core dependency for date and time calculations in cron parsing. Version 1.0.7 specifically improved compatibility with newer versions of this package.","package":"python-dateutil"}],"imports":[{"symbol":"AWSCron","correct":"from pyawscron import AWSCron"}],"quickstart":{"code":"import datetime\nfrom pyawscron import AWSCron\n\ndef main():\n    # An AWS cron expression: at 05:00 AM (UTC) on the 4th of every month.\n    # '?' in day-of-week indicates \"no specific day of the week\" to avoid conflict\n    aws_cron = AWSCron(\"0 5 4 * ? *\")\n\n    # Get the next 5 schedule occurrences from a specific start time\n    start_dt = datetime.datetime.utcnow().replace(second=0, microsecond=0, tzinfo=datetime.timezone.utc)\n    print(f\"Next 5 occurrences from {start_dt.isoformat()}:\")\n    for dt in aws_cron.get_next_n_schedule(start_dt, 5):\n        print(dt)\n\nif __name__ == \"__main__\":\n    main()","lang":"python","description":"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."},"warnings":[{"fix":"Always consult AWS EventBridge/CloudWatch cron documentation. This library is designed specifically for AWS syntax.","message":"AWS cron expressions differ significantly from standard Unix cron. Be aware of unique wildcards like '?', 'L', 'W', '#' and different field order/interpretation (e.g., year field is optional in AWS).","severity":"gotcha","affected_versions":"<1.0.0"},{"fix":"Ensure that if Day-of-month or Day-of-week has a specific value or '*', the other field uses '?' to indicate 'no specific value'.","message":"You cannot use the '*' wildcard in both the Day-of-month and Day-of-week fields simultaneously. If one is specified with '*', the other must use '?' (question mark).","severity":"gotcha","affected_versions":"All"},{"fix":"Upgrade to 1.0.6 or newer for correct 'W' wildcard behavior. Understand its specific meaning beyond a simple 'weekday'.","message":"The 'W' wildcard in the Day-of-month field specifies the weekday closest to the given day. For example, '3W' means the weekday closest to the 3rd of the month. Issue 56 (fixed in 1.0.6) addressed cases where 'W' interacted incorrectly with non-existent dates.","severity":"gotcha","affected_versions":"<1.0.6"},{"fix":"For potentially numerous occurrences, prefer `get_next_n_schedule` for an iterative approach or process smaller date ranges.","message":"The `get_all_schedule_bw_dates` method returns a list of all matching datetimes within a range and has no built-in limit. For large or long date ranges, this can consume significant memory.","severity":"gotcha","affected_versions":"All"},{"fix":"Upgrade to `pyawscron` version 1.0.7 or newer to benefit from relaxed `python-dateutil` dependency constraints.","message":"Older versions of `pyawscron` (prior to 1.0.7) had stricter dependency constraints on `python-dateutil`, potentially causing conflicts when used in environments with newer `python-dateutil` versions.","severity":"gotcha","affected_versions":"<1.0.7"}],"env_vars":null,"last_verified":"2026-04-13T00:00:00.000Z","next_check":"2026-07-12T00:00:00.000Z"}