cronsim is a Python library (current version 2.7) for parsing cron expressions and simulating their execution. It allows calculating the next scheduled run time based on a given start date. It receives low but steady maintenance, with updates for bug fixes and minor features.
pip install cronsimVerified import paths — ran on the pinned version, not inferred.
Initialize CronSim with a cron expression and use the `.next()` method to find the next scheduled run after a given datetime object.
Review the `CHANGELOG.md` and `README.md` for specific migration steps. Essentially, it's a new library requiring a full re-implementation of cron logic.
Ensure your project's Python environment is 3.10 or newer. Upgrade your Python interpreter if necessary.
If you need to include `start_date` as a potential run time, you might need to check `start_date` against the cron expression separately or adjust `start_date` slightly backwards (e.g., by 1 microsecond) before calling `next()`.
Review and correct the cron expression to ensure all fields adhere to the standard cron syntax and allowed value ranges (e.g., minutes 0-59, hours 0-23). For example, '123 * * * *' would cause a 'Bad minute' error because 123 is an invalid minute value.
Catch the `StopIteration` exception to gracefully handle the end of the iteration. Alternatively, adjust the cron expression or the start date if you expect more matching datetimes, or consider that the schedule simply has no more occurrences within the simulated timeframe.
Ensure `cronsim` is installed in the correct Python environment using `pip install cronsim`. If running a script via a cron job, specify the absolute path to the Python interpreter that has `cronsim` installed (e.g., `/usr/bin/python3 /path/to/your_script.py`) or activate the virtual environment within the cron job.
No dependency data recorded yet.