A Python cron expression matcher
CronPy lets you check if a Unix timestamp matches a cron expression such as:
*/5 * * * *→ every 5 minutes0 0 * * *→ every day at midnight@hourly,@daily,@weekly,@monthly,@yearly→ aliases for common schedules
- Supports standard 5-part cron expressions (minute, hour, day-of-month, month, day-of-week)
- Supports wildcards (
*), step values (*/n), lists, and ranges - Accepts month names (
JAN–DEC) and day-of-week names (MON–SUN) - Handles common aliases like
@dailyand@hourly - Compatible with Unix timestamps
Clone the repository and place cronpy.py in your project:
git clone https://github.com/MichaelSekora/cronpy.git
cd cronpyFirst, import the CronPy class:
from cronpy import CronPy
# Example1: Check if the current time matches "every 5 minutes"
if CronPy.getmatch("*/3 * * * *"):
print("This is a 3-minute mark!")
# Example2: Unix timestamp (Jan 2, 2025, 00:00:00 UTC)
timestamp = 1735862400
if CronPy.getmatch("0 0 * * *", timestamp):
print("This matches midnight")
else:
print("Not midnight at this timestamp")