Skip to content

MichaelSekora/CronPy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

CronPy

A Python cron expression matcher

CronPy lets you check if a Unix timestamp matches a cron expression such as:

  • */5 * * * * → every 5 minutes
  • 0 0 * * * → every day at midnight
  • @hourly, @daily, @weekly, @monthly, @yearly → aliases for common schedules

Features

  • 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 (JANDEC) and day-of-week names (MONSUN)
  • Handles common aliases like @daily and @hourly
  • Compatible with Unix timestamps

Installation

Clone the repository and place cronpy.py in your project:

git clone https://github.com/MichaelSekora/cronpy.git
cd cronpy

Usage

Importing

First, 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")

About

CronPy lets you check if a Unix timestamp matches a cron expression

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages